public override void Init(int nrows1, int ncols) { nrows = nrows1; vals = new SparseFloatVector[ncols]; for (int i = 0; i < ncols; i++) { vals[i] = new SparseFloatVector(new int[0], new float[0], nrows); } }
public override void Init(int nrows, int ncolumns1) { ncolumns = ncolumns1; vals = new SparseFloatVector[nrows]; for (int i = 0; i < nrows; i++) { vals[i] = new SparseFloatVector(new int[0], new float[0], ncolumns); } }
public override MatrixIndexer ExtractRows(IList <int> rows) { SparseFloatVector[] r = new SparseFloatVector[vals.Length]; for (int i = 0; i < vals.Length; i++) { r[i] = (SparseFloatVector)vals[i].SubArray(rows); } return(new SparseColumnFloatMatrixIndexer { vals = r, nrows = rows.Count }); }
public override object Clone() { if (vals == null) { return(new SparseColumnFloatMatrixIndexer()); } SparseFloatVector[] v = new SparseFloatVector[vals.Length]; for (int i = 0; i < v.Length; i++) { v[i] = (SparseFloatVector)vals[i].Clone(); } return(new SparseColumnFloatMatrixIndexer { vals = v, nrows = nrows }); }
public override void Set(float[,] value) { nrows = value.GetLength(0); vals = new SparseFloatVector[value.GetLength(1)]; for (int i = 0; i < vals.Length; i++) { List <int> v = new List <int>(); for (int j = 0; j < nrows; j++) { if (value[j, i] == 0) { continue; } v.Add(j); } int[] v1 = v.ToArray(); float[] x = new float[v1.Length]; for (int j = 0; j < v1.Length; j++) { x[j] = value[v1[j], i]; } vals[i] = new SparseFloatVector(v1, x, nrows); } }
public override void Set(double[,] value) { ncolumns = value.GetLength(1); vals = new SparseFloatVector[value.GetLength(0)]; for (int i = 0; i < vals.Length; i++) { List <int> v = new List <int>(); for (int j = 0; j < ncolumns; j++) { if (value[i, j] == 0) { continue; } v.Add(j); } int[] v1 = v.ToArray(); float[] x = new float[v1.Length]; for (int j = 0; j < v1.Length; j++) { x[j] = (float)value[i, v1[j]]; } vals[i] = new SparseFloatVector(v1, x, ncolumns); } }