I'm trying to find a formula for

copy[3] = b.data[0]
copy[4] = b.data[1]
copy[5] = b.data[2]
copy[9] = b.data[3]
copy[10] = b.data[4]
copy[11] = b.data[5]

letting the right hand side be b.data, I can see this is like

copy[3] = b.data[0] multiply by 2, add 3
copy[4] = b.data[1] multiply by 2, add 2
copy[5] = b.data[2] multiply by 2, add 1
copy[9] = b.data[3] multiply by 2, add 3
copy[10] = b.data[4] multiply by 2, add 2
copy[11] = b.data[5] multiply by 2, add 1

there's obviously a modulo pattern going on so I've tried

copy[i*2 + (rows +(-1*i) % (rows + 1))] = b.data_;

(rows = 3)

which gives me the adding pattern 3 2 1 0 3 2 1 0

however I need to miss out the 0, can anyone see how to do this?

Thanks in advance!

Edited 6 Years Ago by sexyzebra19: n/a

To go from the right hand side index to the left handside index the maths computationally is as follows

int cycle_rhs(3), cycle_rhs(6);
int temp =  x/cycle_rhs; //this gives a floor so no remainder
int temp2 = cycle_lhs * temp;
/*
0 , 1, 2 ->0
3, 4, 5 -> 6
*/
int offset_lhs(3);

y = temp2 + offset_lhs + x%cycle_rhs;

I note though that you are doing a matrix mthod why
not have a

std::vector<int> get_column(int id);
bool resize_matrix(int width, int height, int value = 0);
bool set_column(std::vector<int> &vals);

set of methods

I'm trying to find a formula for

copy[3] = b.data[0]
copy[4] = b.data[1]
copy[5] = b.data[2]
copy[9] = b.data[3]
copy[10] = b.data[4]
copy[11] = b.data[5]

letting the right hand side be b.data, I can see this is like

copy[3] = b.data[0] multiply by 2, add 3
copy[4] = b.data[1] multiply by 2, add 2
copy[5] = b.data[2] multiply by 2, add 1
copy[9] = b.data[3] multiply by 2, add 3
copy[10] = b.data[4] multiply by 2, add 2
copy[11] = b.data[5] multiply by 2, add 1

there's obviously a modulo pattern going on so I've tried

copy[i*2 + (rows +(-1*i) % (rows + 1))] = b.data_;

(rows = 3)

which gives me the adding pattern 3 2 1 0 3 2 1 0

however I need to miss out the 0, can anyone see how to do this?

Thanks in advance!

Thanks for the reply tetron but I didn't really understand your method...

EDIT - solved it another way.

Edited 6 Years Ago by sexyzebra19: n/a

This question has already been answered. Start a new discussion instead.