Vector offset!

Hi!

How can I specify that indexing of float4 should start at index 1 instead of 0? Example:

Offset = 1;
for (i = 0; i < Len; i++) v[i+Offset] = 1;

How can the same be achieved if the v is declared as float4 *?

Thanks!
Atmapuri

For offset, you should be sure to not overflow of array :


Offset = 1;
for (i = Offset; i < Len; i++)
{
  v[i] = 1;
}

or


Offset = 1;
for (i = 0; i < Len -Offset; i++)
{
  v[i+Offset] = 1;
}

For assign to float4, pending expert post, you can try:


v[i] = (float4) (1.0, 1.0, 1.0, 1.0);

or


v[i] = (float4) 1.0;

or


v[i].x = 1.0;
v[i].y = 1.0;
v[i].z = 1.0;
v[i].w = 1.0;

Hope it can help.