Get the values of a matrix column and assign them to a vector.
BOOL GetColumn( vectorbase & vb, UINT wIndexCol )
Returns TRUE on success and FALSE on failure.
EX1
// Get a vector from a matrix column void matrixbase_GetColumn_ex1() { matrix<double> mat1 = { {1, 1, 1, 1}, {2, 4, 6, 8}, {3, 6, 9, 12} }; MatrixPage MatPg1; MatPg1.Create("Origin"); MatrixLayer MatLy1 = MatPg1.Layers(0); Matrix Mat1(MatLy1); Mat1 = mat1; printf(" The input matrix is %s.\n",Mat1.GetName()); vector v; int ii; int rc=Mat1.GetColumn(v, 2); // Get 3rd column(as the index starts 0) of Mat1 into v if(!rc) printf(" Error: GetColumn failed.\n"); else { printf(" The gotten vector from 3rd column is:\n"); for(ii = 0; ii < v.GetSize(); ii++) // Output cast elements of vectors printf("\t%g",v[ii]); printf("\n"); } vector v2; rc=Mat1.GetColumn(v2, 4); // Command Error! Index out of range. if(!rc) printf(" Error: GetColumn failed.\n"); else { printf(" The gotten vector from 3rd column is:\n"); for(ii = 0; ii < v2.GetSize(); ii++) // Output cast elements of vectors printf("\t%g",v2[ii]); printf("\n"); } }
Get the values of a matrix column and assign them to a vector. The column is specified by a 0 based column index. If the matrix column and vector do not have the same size then the vector is dynamically resized.
matrixbase::SetColumn, matrixbase::GetRow, matrixbase::SetRow, matrixbase::GetAsVector, matrixbase::SetByVector
origin.h