free( mtx );
}
-float *AllocateFloatVec( int l1 )
+double *AllocateFloatVec( int l1 )
{
- float *vec;
+ double *vec;
- vec = (float *)calloc( (unsigned int)l1, sizeof( float ) );
+ vec = (double *)calloc( (unsigned int)l1, sizeof( double ) );
if( vec == NULL )
{
fprintf( stderr, "Allocation error ( %d fload vec )\n", l1 );
return( vec );
}
-void FreeFloatVec( float *vec )
+void FreeFloatVec( double *vec )
{
free( (char *)vec );
}
-float **AllocateFloatHalfMtx( int ll1 )
+double **AllocateFloatHalfMtx( int ll1 )
{
- float **mtx;
+ double **mtx;
int i;
- mtx = (float **)calloc( (unsigned int)ll1+1, sizeof( float * ) );
+ mtx = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
if( mtx == NULL )
{
fprintf( stderr, "Allocation error ( %d fload halfmtx )\n", ll1 );
}
for( i=0; i<ll1; i++ )
{
- mtx[i] = (float *)calloc( ll1-i, sizeof( float ) );
+ mtx[i] = (double *)calloc( ll1-i, sizeof( double ) );
if( !mtx[i] )
{
- fprintf( stderr, "Allocation error( %d floathalfmtx )\n", ll1 );
+ fprintf( stderr, "Allocation error( %d doublehalfmtx )\n", ll1 );
exit( 1 );
}
}
return( mtx );
}
-float **AllocateFloatMtx( int ll1, int ll2 )
+double **AllocateFloatMtx( int ll1, int ll2 )
{
- float **mtx;
+ double **mtx;
int i;
- mtx = (float **)calloc( (unsigned int)ll1+1, sizeof( float * ) );
+ mtx = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
if( mtx == NULL )
{
fprintf( stderr, "Allocation error ( %d x %d fload mtx )\n", ll1, ll2 );
{
for( i=0; i<ll1; i++ )
{
- mtx[i] = (float *)calloc( ll2, sizeof( float ) );
+ mtx[i] = (double *)calloc( ll2, sizeof( double ) );
if( !mtx[i] )
{
- fprintf( stderr, "Allocation error( %d x %d floatmtx )\n", ll1, ll2 );
+ fprintf( stderr, "Allocation error( %d x %d doublemtx )\n", ll1, ll2 );
exit( 1 );
}
}
return( mtx );
}
-void FreeFloatHalfMtx( float **mtx, int n )
+void FreeFloatHalfMtx( double **mtx, int n )
{
int i;
for( i=0; i<n; i++ )
{
- if( mtx[i] ) FreeFloatVec( mtx[i] );
+ if( mtx[i] ) FreeFloatVec( mtx[i] ); mtx[i] = NULL;
}
free( mtx );
}
-void FreeFloatMtx( float **mtx )
+void FreeFloatMtx( double **mtx )
{
int i;
for( i=0; mtx[i]; i++ )
{
- FreeFloatVec( mtx[i] );
+ if( mtx[i] ) FreeFloatVec( mtx[i] ); mtx[i] = NULL;
}
free( mtx );
}
+int *AllocateIntVecLarge( unsigned long long ll1 )
+{
+ int *vec;
+
+ vec = (int *)calloc( ll1, sizeof( int ) );
+ if( vec == NULL )
+ {
+ fprintf( stderr, "Allocation error( %lld int vec )\n", ll1 );
+ exit( 1 );
+ }
+ return( vec );
+}
+
int *AllocateIntVec( int ll1 )
{
int *vec;
free( (char *)vec );
}
-float **AllocateFloatTri( int ll1 )
+double **AllocateFloatTri( int ll1 )
{
- float **tri;
+ double **tri;
int i;
- tri = (float **)calloc( (unsigned int)ll1+1, sizeof( float * ) );
+ tri = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
if( !tri )
{
- fprintf( stderr, "Allocation error ( float tri )\n" );
+ fprintf( stderr, "Allocation error ( double tri )\n" );
exit( 1 );
}
for( i=0; i<ll1; i++ )
return( tri );
}
-void FreeFloatTri( float **tri )
+void FreeFloatTri( double **tri )
{
/*
- float **x;
+ double **x;
x = tri;
while( *tri != NULL ) free( *tri++ );
free( x );
}
if( ll2 )
{
- for( i=0; i<ll1; i++ )
- {
- mtx[i] = AllocateIntVec( ll2 );
- }
+ for( i=0; i<ll1; i++ ) mtx[i] = AllocateIntVec( ll2 );
+ }
+ else
+ {
+ for( i=0; i<ll1; i++ ) mtx[i] = NULL;
+ }
+ mtx[ll1] = NULL;
+ return( mtx );
+}
+
+int **AllocateIntMtxLarge( unsigned long long ll1, unsigned long long ll2 )
+{
+ unsigned long long i;
+ int **mtx;
+
+ mtx = (int **)calloc( ll1+1, sizeof( int * ) );
+ if( !mtx )
+ {
+ fprintf( stderr, "Allocation error( %lld x %lld int mtx )\n", ll1, ll2 );
+ exit( 1 );
+ }
+ if( ll2 )
+ {
+ for( i=0; i<ll1; i++ ) mtx[i] = AllocateIntVecLarge( ll2 );
+ }
+ else
+ {
+ for( i=0; i<ll1; i++ ) mtx[i] = NULL;
}
mtx[ll1] = NULL;
return( mtx );
free( cub );
}
-void freeintmtx( int **mtx, int ll1, int ll2 )
+void freeintmtx( int **mtx, int ll1 )
{
int i;
- for( i=0; i<ll1; i++ )
- free( (char *)mtx[i] );
+ for( i=0; i<ll1; i++ ) free( (char *)mtx[i] );
free( (char *)mtx );
}
int i;
for( i=0; mtx[i]; i++ )
- free( (char *)mtx[i] );
+ {
+ if( mtx[i] ) free( (char *)mtx[i] ); mtx[i] = NULL;
+ }
free( (char *)mtx );
}
{
double *vec;
- vec = (double *)calloc( ll1, sizeof( double ) );
+ vec = (double *)calloc( ll1, sizeof( double ) ); // filled with 0.0
return( vec );
}
int i;
for( i=0; cub[i]; i++ )
{
- FreeIntMtx( cub[i] );
+ if( cub[i] ) FreeIntMtx( cub[i] ); cub[i] = NULL;
}
free( cub );
}
+double **AllocateDoubleHalfMtx( int ll1 )
+{
+ double **mtx;
+ int i;
+
+ mtx = (double **)calloc( (unsigned int)ll1+1, sizeof( double * ) );
+ if( mtx == NULL )
+ {
+ fprintf( stderr, "Allocation error ( %d double halfmtx )\n", ll1 );
+ exit( 1 );
+ }
+ for( i=0; i<ll1; i++ )
+ {
+ mtx[i] = (double *)calloc( ll1-i, sizeof( double ) );
+ if( !mtx[i] )
+ {
+ fprintf( stderr, "Allocation error( %d double halfmtx )\n", ll1 );
+ exit( 1 );
+ }
+ }
+ mtx[ll1] = NULL;
+ return( mtx );
+}
+
double **AllocateDoubleMtx( int ll1, int ll2 )
{
int i;
return mtx;
}
+void FreeDoubleHalfMtx( double **mtx, int n )
+{
+ int i;
+
+ for( i=0; i<n; i++ )
+ {
+ if( mtx[i] ) FreeFloatVec( mtx[i] ); mtx[i] = NULL;
+ }
+ free( mtx );
+}
void FreeDoubleMtx( double **mtx )
{
int i;
free( mtx );
}
-float ***AllocateFloatCub( int ll1, int ll2, int ll3 )
+double ***AllocateFloatCub( int ll1, int ll2, int ll3 )
{
int i;
- float ***cub;
+ double ***cub;
- cub = (float ***)calloc( ll1+1, sizeof( float ** ) );
+ cub = (double ***)calloc( ll1+1, sizeof( double ** ) );
if( !cub )
{
- fprintf( stderr, "cannot allocate float cube.\n" );
+ fprintf( stderr, "cannot allocate double cube.\n" );
exit( 1 );
}
for( i=0; i<ll1; i++ )
return( cub );
}
-void FreeFloatCub( float ***cub )
+void FreeFloatCub( double ***cub )
{
int i;