Changeset 14277 for branches/symbreg-factors-2650/HeuristicLab.ExtLibs/HeuristicLab.Igraph/0.8.0-pre/HeuristicLab.Igraph-0.8.0-pre/Wrappers/Matrix.cs
- Timestamp:
- 09/08/16 11:41:45 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650/HeuristicLab.ExtLibs/HeuristicLab.Igraph/0.8.0-pre/HeuristicLab.Igraph-0.8.0-pre/Wrappers/Matrix.cs
r14276 r14277 39 39 DllImporter.igraph_matrix_copy(matrix, other.NativeInstance); 40 40 } 41 public Matrix(double[,] mat) { 42 if (mat == null) throw new ArgumentNullException("mat"); 43 matrix = new igraph_matrix_t(); 44 var nrows = mat.GetLength(0); 45 var ncols = mat.GetLength(1); 46 DllImporter.igraph_matrix_init(matrix, nrows, ncols); 47 var colwise = new double[ncols * nrows]; 48 for (var j = 0; j < ncols; j++) 49 for (var i = 0; i < nrows; i++) 50 colwise[j * nrows + i] = mat[i, j]; 51 DllImporter.igraph_vector_init_copy(matrix.data, colwise); 52 } 41 53 ~Matrix() { 42 54 DllImporter.igraph_matrix_destroy(matrix); … … 48 60 matrix = null; 49 61 GC.SuppressFinalize(this); 62 } 63 64 public void Fill(double v) { 65 DllImporter.igraph_matrix_fill(matrix, v); 66 } 67 68 public void Transpose() { 69 DllImporter.igraph_matrix_transpose(matrix); 70 } 71 72 public void Scale(double by) { 73 DllImporter.igraph_matrix_scale(matrix, by); 50 74 } 51 75
Note: See TracChangeset
for help on using the changeset viewer.