kspaceFirstOrder3D-OMP  1.0
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
MatrixClasses/LongMatrix.cpp
Go to the documentation of this file.
00001 
00033 #include <iostream>
00034 
00035 #include <MatrixClasses/LongMatrix.h>
00036 
00037 #include <Utils/ErrorMessages.h>
00038 
00039 //----------------------------------------------------------------------------//
00040 //                              Constants                                     //
00041 //----------------------------------------------------------------------------//
00042 
00043 
00044 //----------------------------------------------------------------------------//
00045 //                              Definitions                                   //
00046 //----------------------------------------------------------------------------//
00047 
00048 
00049 
00050 //----------------------------------------------------------------------------//
00051 //                              Implementation                                //
00052 //                              public methods                                //
00053 //----------------------------------------------------------------------------//
00054 
00059 TLongMatrix::TLongMatrix(struct TDimensionSizes DimensionSizes) : 
00060                 TBaseLongMatrix() 
00061 {
00062      
00063     pDimensionSizes = DimensionSizes;
00064        
00065      
00066     pTotalElementCount = pDimensionSizes.X *
00067                          pDimensionSizes.Y *
00068                          pDimensionSizes.Z;
00069 
00070     pTotalAllocatedElementCount = pTotalElementCount;
00071     
00072     pDataRowSize       = pDimensionSizes.X;
00073 
00074     p2DDataSliceSize   = pDimensionSizes.X *
00075                          pDimensionSizes.Y;                        
00076             
00077     
00078     AllocateMemory();
00079 }// end of TRealMatrixData
00080 //-----------------------------------------------------------------------------
00081 
00082 
00083 
00091 void TLongMatrix::ReadDataFromHDF5File(THDF5_File & HDF5_File, const char * MatrixName){
00092     
00093 
00094     if (HDF5_File.ReadMatrixDataType(MatrixName) != THDF5_File::hdf5_mdt_long){        
00095         char ErrorMessage[256];
00096         sprintf(ErrorMessage,Matrix_ERR_FMT_MatrixNotLong,MatrixName);                        
00097         throw ios::failure(ErrorMessage);       
00098     }
00099     
00100     
00101     if (HDF5_File.ReadMatrixDomainType(MatrixName) != THDF5_File::hdf5_mdt_real){
00102         char ErrorMessage[256];
00103         sprintf(ErrorMessage,Matrix_ERR_FMT_MatrixNotReal,MatrixName);                        
00104         throw ios::failure(ErrorMessage);       
00105     }
00106     
00107     
00108     HDF5_File.ReadCompleteDataset(MatrixName,pDimensionSizes,pMatrixData);
00109     
00110 }// end of LoadDataFromMatlabFile
00111 //------------------------------------------------------------------------------
00112     
00113 
00114 
00115 
00119 void TLongMatrix::RecomputeIndices()
00120 {
00121     
00122     for (size_t i = 0; i< pTotalElementCount; i++){
00123         pMatrixData[i]--;
00124     }    
00125     
00126 }// end of RecomputeIndices
00127 //------------------------------------------------------------------------------
00128 
00129 
00130 
00139 void TLongMatrix::WriteDataToHDF5File(THDF5_File & HDF5_File, const char * MatrixName, const int CompressionLevel){
00140     
00141     
00142     HDF5_File.WriteCompleteDataset(MatrixName,pDimensionSizes,pMatrixData);
00143     
00144     HDF5_File.WriteMatrixDataType  (MatrixName, THDF5_File::hdf5_mdt_long);        
00145     HDF5_File.WriteMatrixDomainType(MatrixName, THDF5_File::hdf5_mdt_real);
00146     
00147     
00148 }// end of WriteDataToHDF5File
00149 //---------------------------------------------------------------------------
00150 
00151 
00152 //----------------------------------------------------------------------------//
00153 //                              Implementation                                //
00154 //                             protected methods                              //
00155 //----------------------------------------------------------------------------//
00156 
00157 
00158 //----------------------------------------------------------------------------//
00159 //                              Implementation                                //
00160 //                              private methods                               //
00161 //----------------------------------------------------------------------------//
 All Classes Files Functions Variables Typedefs Enumerations