// test that we can create an empty file and add matrices public static void CreateMatrixTest(string file) { int zones = 3; double[,] testblock; string[] matrixNames = { "mat1", "mat2" }; OmxWriteStream ws = OmxFile.Create(file, zones, true); // NOTE: cannot create data type until after file stream is created H5DataTypeId matrixDataTypes = H5T.copy(H5T.H5Type.NATIVE_DOUBLE); for (int i = 0; i < matrixNames.Length; i++) { ws.AddMatrix(matrixNames[i], matrixDataTypes); } ws.Close(); OmxReadStream rs = OmxFile.OpenReadOnly(file); for (int i = 0; i < matrixNames.Length; i++) { testblock = rs.GetMatrixBlock <double>(matrixNames[i], 0, 0, 1, 1); } Console.WriteLine("mat shape is {0},{1}", rs.Shape[0], rs.Shape[1]); Console.WriteLine("mat names are {0},{1}", rs.MatrixNames[0], rs.MatrixNames[1]); Console.WriteLine("mat data type: {0},{1}", H5T.getClass(rs.GetMatrixDataType(matrixNames[0])), H5T.getClass(rs.GetMatrixDataType(matrixNames[1]))); rs.Close(); }
// Test that we can read an OMX file with attributes and tables public static void ReadTest(string file) { OmxReadStream rs = OmxFile.OpenReadOnly(file); Console.WriteLine("OMX version is {0}", rs.OmxVersion); Console.WriteLine("mat shape is {0},{1}", rs.Shape[0], rs.Shape[1]); Console.WriteLine("first mat names is {0}", rs.MatrixNames[0]); Console.WriteLine("first mat data type is {0}", H5T.getClass(rs.GetMatrixDataType(rs.MatrixNames[0]))); rs.Close(); }