Esempio n. 1
0
        // test read/write row function
        public static void ReadWriteRowTest(string file, string matName)
        {
            OmxWriteStream ws = OmxFile.OpenReadWrite(file);

            Console.WriteLine("mat shape is {0},{1}", ws.Shape[0], ws.Shape[1]);

            H5DataTypeId dt = ws.GetMatrixDataType(matName);

            // blocks we are reading need to match the data type of the matrix
            var rowData  = new double[ws.Shape[0]];
            var rowData2 = new double[ws.Shape[0]];

            rowData = ws.GetMatrixRow <double>(matName, 2);

            rowData[2] = rowData[2] + 1.0;
            ws.SetMatrixRow <double>(matName, 2, rowData);
            rowData2 = ws.GetMatrixRow <double>(matName, 2);

            if (rowData.Sum() == rowData2.Sum())
            {
                Console.WriteLine("Row Read/Write successful");
            }
            else
            {
                Console.WriteLine("Read/Write mismatch");
            }
            ws.Close();
        }