Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 public void Dispose()
 {
     if (matrix == null)
     {
         return;
     }
     DllImporter.igraph_matrix_destroy(matrix);
     matrix = null;
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 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);
        }