a question about the assignment operator '=' for jitter matrices in javascript
Jul 04 2012 | 9:04 pm
Hello. I'm writing a javascript patch to manipulate some data stored in a jitter matrix and I am puzzled by something seems like it ought to be simple and straightforward. Can someone please help me with the following piece of code?
//create two matrices var matrix1= new JitterMatrix(1,'float32',3,3); var matrix2 = new JitterMatrix(1,'float32',3,3); matrix1.setcell2d(1,1,5); //set the (1,1) element of matrix1 equal to 5 post(matrix1.getcell(1,1)); // -->5 so far so good //Copy the values from matrix1 to matrix2 matrix2 = matrix1; //If an element in matrix1 element equals 5, //the corresponding element in matrix2 should equal 1. //Otherwise it should equal 0 matrix2.op('==',5); post(matrix1.getcell(1,1)); // -->1 ??????????????
It seems that by operating on matrix2 I have changed the value of matrix1. I suspect that after the '=' operator matrix1 and matrix2 are referring to the same data. Is this correct? What is the correct way to perform this type of operation in javascript/jitter?
Thanks,
Adam