public Matrix(int nrow, int ncol) { if (nrow < 0 || ncol < 0) { throw new ArgumentException("Rows and Columns must be >= 0"); } matrix = new igraph_matrix_t(); DllImporter.igraph_matrix_init(matrix, nrow, ncol); }
public Matrix(double[,] mat) { if (mat == null) { throw new ArgumentNullException("mat"); } matrix = new igraph_matrix_t(); var nrows = mat.GetLength(0); var ncols = mat.GetLength(1); DllImporter.igraph_matrix_init(matrix, nrows, ncols); var colwise = new double[ncols * nrows]; for (var j = 0; j < ncols; j++) { for (var i = 0; i < nrows; i++) { colwise[j * nrows + i] = mat[i, j]; } } DllImporter.igraph_vector_init_copy(matrix.data, colwise); }