How to index vector types? Like double2

A relatively simple question this time. I’m working on modifying some code to load two values as a vector type (double2) instead of as two doubles. Here’s a sample of the code I’m trying to use:

__global__ void mul_kernel(double2 g_z)

{

        int threadID = blockIdx.x * blockDim.x + threadIdx.x;

	double2 g_z_old = g_z[threadID];

        g_z[threadID] = make_double2(g_z_old.x *  g_z_old.x - g_z_old.y *  g_z_old.y, g_z_old.x *  g_z_old.y * 2.0);

}

And I get this error twice:

error: no operator “” matches these operands

        operand types are: double2 [ int ]

So how am I supposed to index a vector type?

In that code, g_z is a value, not an array or pointer. The compiler error is perfectly correct, you cannot index that variable.

facepalm

Thank you. :blush: