示例#1
0
 public Matrix(Matrix other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     matrix = new igraph_matrix_t();
     DllImporter.igraph_matrix_copy(matrix, other.NativeInstance);
 }
示例#2
0
 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);
 }
示例#3
0
 public void Dispose()
 {
     if (matrix == null)
     {
         return;
     }
     DllImporter.igraph_matrix_destroy(matrix);
     matrix = null;
     GC.SuppressFinalize(this);
 }
示例#4
0
        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);
        }