//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 ??????????????
Ah. If I do the assignment with a jit.expr object the problem goes away.
matrix2 = matrix1;
both variables refer (in C-Speak: point to) the same data.
If you want a deep copy, you need to write your own routine. This is useful with complex data structures, because you may want copies of certain components while using references to others.
And, if jit.expr gets you through the night, then use that.
The frommatrix() function in JitterMatrix will do a deep copy of the matrix values. I believe you would call as follows:
matrix2.frommatrix( matrix1 );
matrix2.frommatrix( matrix1.name );
Thank you. That answers my question.
C74 RSS Feed | © Copyright Cycling '74