On most systems, the Library does not need any special initialization. Some (hopefully obsolete) C++ environments however fail to initialize static variables. All vital static variables in the Library may be forcefully initialized by calling function InitMatType.
It is important to keep in mind that through the Library, a pointer is considered as allocated unless it has value "NULL". The Library may attempt to deallocate any pointer which is not set "NULL". If a pointer was obtained from a Library function, the Library normally is responsible for deallocation of it (exceptions from this rule are mentioned wherever necessary); therefore the application should not attempt to change such pointer in any way. If an allocated pointer was given to a Library function and is then returned as a result, it may appear reallocated or even deallocated - check remarks for that Library function. Finally, the Library provides various tools for working with dynamically allocated objects such as vectors and matrices. Using them is encouraged, although is not mandatory.Function | Purpose |
InitMatType | Initialization of static variables.
|
GetVectorMemory | Allocating a vector object.
|
FreeVectorMemory | Deallocating a vector object.
|
GetMatrixMemory | Allocating a matrix object.
|
FreeMatrixMemory | Deallocating a matrix object.
|
GetMatrix3Memory | Allocating a 3D matrix object.
|
FreeMatrix3Memory | Deallocating a 3D matrix object.
|
Boolean InitMatType ( |
) |
This function performs initialization of vital data kept in Library's static fields. Using it is necessary only in certain C++ environments, which fail to perform the initialization automatically. It is absolutely cheap and completely harmless to call this function multiple times, however an application needs to call it only once from the application's top.
The function always returns True, there is no need to check on it.
Boolean GetVectorMemory ( |
vectortype & V, |
The function allocates N elements of type *V, shifts them according to the value of Shift and returns as allocated vector V. As a result, the vector elements are accessible as V[i] where i ranges as [Shift ... Shift+N-1].
The function returns True if memory was successfully allocated, and False otherwise. If allocation fails, V returns NULL.
NOTE 1: This function does not check if V was previously allocated and does not try to deallocate it. It is responsibility of the application to deallocate V prior calling GetVectorMemory, if necessary.
NOTE 2: This function does not initialize the allocated memory.
void FreeVectorMemory ( |
vectortype & V, |
The function checks if vector V was allocated, and if it was, deallocates it. V always returns NULL.
NOTE 1: The value of Shift must be the same as that used at allocation of the vector. If this condition does not hold, the application may crash in unpredictable place.
NOTE 2: It is perfectly Ok to give V=NULL to this function.
Boolean GetMatrixMemory ( |
matrixtype & A, |
The function returns matrix A allocated as N elements of type *A, shifted by the value of ShiftN, each of them allocated as vectors of length M with offset ShiftM. As a result, the matrix' elements are accessible as A[i][j] where index i ranges as [ShiftN ... ShiftN+N-1] and index j - as [ShiftM ... ShiftM+M-1].
The function returns True if memory was successfully allocated, and False otherwise. If allocation fails, A returns NULL.
NOTE 1: This function does not check if A was previously allocated and does not try to deallocate it. It is responsibility of the application to deallocate A prior calling GetMatrixMemory, if necessary.
NOTE 2: This function does not initialize the allocated memory.
void FreeMatrixMemory ( |
matrixtype & A, |
The function checks if matrix A was allocated, and if it was, deallocates it. A always returns NULL.
NOTE 1: The values of N, ShiftN and ShiftM must be same as those used at allocation of the matrix. If this condition does not hold, the application may crash in unpredictable place.
NOTE 2: It is perfectly Ok to give A=NULL to this function.
Boolean GetMatrix3Memory ( |
matrix3type & A, |
The function returns 3D matrix A allocated as N elements of type *A, shifted by the value of ShiftN, each of them allocated as matrices of "vertical" dimension/offset M/ShiftM and "horizontal" dimension/offset K/ShiftK. As a result, the matrix' elements are accessible as A[i][j][k] where index i ranges as [ShiftN ... ShiftN+N-1], index j - as [ShiftM ... ShiftM+M-1] and index k - as [ShiftK ... ShiftK+K-1].
The function returns True if memory was successfully allocated, and False otherwise. If allocation fails, A returns NULL.
NOTE 1: This function does not check if A was previously allocated and does not try to deallocate it. It is responsibility of the application to deallocate A prior calling GetMatrix3Memory, if necessary.
NOTE 2: This function does not initialize the allocated memory.
void FreeMatrix3Memory ( |
matrix3type & A, |
The function checks if 3D matrix A was allocated, and if it was, deallocates it. A always returns NULL.
NOTE 1: The values of N, M, ShiftN, ShiftM and ShiftK must be same as those used at allocation of the matrix. If this condition does not hold, the application may crash in unpredictable place.
NOTE 2: It is perfectly Ok to give A=NULL to this function.