public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var serializationModel = serializer.Deserialize <MatrixSerializationModel>(reader); if (serializationModel.IsDense) { var storage = DenseColumnMajorMatrixStorage <double> .OfColumnMajorEnumerable( serializationModel.RowCount, serializationModel.ColumnCount, serializationModel.Storage ); var matrix = new DenseMatrix(storage); return(matrix); } else { var storage = SparseCompressedRowMatrixStorage <double> .OfColumnMajorList( serializationModel.RowCount, serializationModel.ColumnCount, serializationModel.Storage ); var matrix = new SparseMatrix(storage); return(matrix); } }
/// <summary> /// Create a new dense matrix as a copy of the given enumerable. /// The enumerable is assumed to be in column-major order (column by column). /// This new matrix will be independent from the enumerable. /// A new memory block will be allocated for storing the matrix. /// </summary> public static DenseMatrix OfColumnMajor(int rows, int columns, IEnumerable <Complex> columnMajor) { return(new DenseMatrix(DenseColumnMajorMatrixStorage <Complex> .OfColumnMajorEnumerable(rows, columns, columnMajor))); }