void FreeMatrix(
DOUBLE* matrix );
void Exception3()
{
{
try
{
matrix = AllocateMatrix( 0, 3 );
}
{
_tprintf( _T("ex1) exception=%d, errcode=%d, function=%s, message=%s\n"),
}
FreeMatrix( matrix );
matrix = NULL;
}
{
try
{
matrix = AllocateMatrix( 32768, 32768 );
}
{
_tprintf( _T("ex2) exception=%d, errcode=%d, function=%s, message=%s\n"),
}
FreeMatrix( matrix );
matrix = NULL;
}
{
try
{
matrix = AllocateMatrix( 5, 5 );
ResetMatrix( matrix, 5, 5 );
}
{
_tprintf( _T("ex3) exception=%d, errcode=%d, function=%s, message=%s\n"),
}
FreeMatrix( matrix );
matrix = NULL;
}
{
try
{
g_rows = 3;
g_cols = 3;
g_matrix = AllocateMatrix( g_rows, g_cols );
ResetMatrix( g_matrix, g_rows, g_cols );
DOUBLE value00 = GetMatrixValue( 0, 0 );
DOUBLE value11 = GetMatrixValue( 1, 1 );
DOUBLE value22 = GetMatrixValue( 2, 2 );
DOUBLE value33 = GetMatrixValue( 3, 3 );
}
{
_tprintf( _T("ex4) exception=%d, errcode=%d, function=%s, message=%s\n"),
}
FreeMatrix( g_matrix );
g_matrix = NULL;
}
}
{
if( rows <= 0 )
if( cols <= 0 )
size_t size = rows * cols;
if( 2*1024*1024/8 < size )
DOUBLE* matrix = (
DOUBLE*)::HeapAlloc( ::GetProcessHeap(), HEAP_ZERO_MEMORY, size*
sizeof(
DOUBLE) );
if( matrix == NULL )
return matrix;
}
void FreeMatrix(
DOUBLE* matrix )
{
if( matrix != NULL )
::HeapFree( ::GetProcessHeap(), 0, matrix );
}
{
if( matrix == NULL )
if( rows != 3 || cols != 3 )
for(
UINT r=0 ; r<rows ; r++ )
for(
UINT c=0 ; c<cols ; c++ )
matrix[r * cols + c] = 0;
matrix[0 * cols + 0] = 1;
matrix[1 * cols + 1] = 1;
matrix[2 * cols + 2] = 1;
}
{
if( g_matrix == NULL )
if( !(0 <= row && row < g_rows) )
if( !(0 <= col && col < g_cols) )
return g_matrix[row * g_cols + col];
}