kspaceFirstOrder3D-OMP
1.0
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
|
00001 00034 #include <string.h> 00035 #include <malloc.h> 00036 00037 #include <MatrixClasses/BaseLongMatrix.h> 00038 00039 #include <Utils/DimensionSizes.h> 00040 #include <Utils/ErrorMessages.h> 00041 00042 00043 //----------------------------------------------------------------------------// 00044 // Constants // 00045 //----------------------------------------------------------------------------// 00046 00047 00048 //----------------------------------------------------------------------------// 00049 // Definitions // 00050 //----------------------------------------------------------------------------// 00051 00052 00053 00054 //----------------------------------------------------------------------------// 00055 // Implementation // 00056 // public methods // 00057 //----------------------------------------------------------------------------// 00058 00063 void TBaseLongMatrix::ZeroMatrix(){ 00064 00065 memset(pMatrixData,0,pTotalAllocatedElementCount*sizeof(long)); 00066 00067 }// end of ZeroMatrix 00068 //------------------------------------------------------------------------------ 00069 00070 00071 00072 //----------------------------------------------------------------------------// 00073 // Implementation // 00074 // protected methods // 00075 //----------------------------------------------------------------------------// 00076 00077 00082 void TBaseLongMatrix::AllocateMemory(){ 00083 /* No memory allocated before this function*/ 00084 00085 pMatrixData = (long *) memalign(SSE_ALIGNMENT,pTotalAllocatedElementCount * sizeof (long)); 00086 00087 if (!pMatrixData) { 00088 fprintf(stderr,Matrix_ERR_FMT_NotEnoughMemory, "TBaseLongMatrix"); 00089 throw bad_alloc(); 00090 } 00091 00092 ZeroMatrix(); 00093 00094 }// end of AllocateMemory 00095 //------------------------------------------------------------------------------ 00096 00100 void TBaseLongMatrix::FreeMemory(){ 00101 00102 if (pMatrixData) free(pMatrixData); 00103 pMatrixData = NULL; 00104 00105 }// end of MemoryDealocation 00106 //------------------------------------------------------------------------------ 00107 00108 00109 00110 00111 //----------------------------------------------------------------------------// 00112 // Implementation // 00113 // private methods // 00114 //----------------------------------------------------------------------------//