libftsh
A Fast Transform for Spherical Harmonics
 All Data Structures Files Functions Variables Defines
Defines | Functions
dmat.c File Reference

Contains simple functions based on the Dense_Matrix struct. More...

#include "libftsh.h"

Defines

#define ENTEREXIT   0

Functions

Dense_Matrix init_dmat_memory (unsigned int n)
void give_dmat_memory (Dense_Matrix *current, Dense_Matrix *previous)
void free_dmat_memory (Dense_Matrix *in)
void dump_bin_dmat (Dense_Matrix *x, FILE *out)
void load_bin_dmat (Dense_Matrix *x, FILE *in)

Detailed Description

Contains simple functions based on the Dense_Matrix struct.

Summary:


Function Documentation

void dump_bin_dmat ( Dense_Matrix x,
FILE *  out 
)

This routine dumps a Dense_Matrix to a file in binary format.

This is efficient, but not human readable.

INPUTS:

  • x -- the Dense_Matrix
  • out -- A pointer to the file to write into. Setting this to stdout makes it write to the screen. If out==NULL we use stdout.

OUTPUT: writes into the file given by out. The writing mode ("wb" or "ab") is determined outside of this routine.

Here is the caller graph for this function:

This routine frees the memory that was given to a Dense_Matrix by init_dmat_memory.

INPUT: in -- the Dense_Matrix to free. it must have been initialized by init_dmat_memory, or we will attempt to free things not gotten by calloc, probaby causing catastrophic failure.

NOTES:

  • If used incorrectly, this routine may yield nasty memory bugs.

Here is the caller graph for this function:

void give_dmat_memory ( Dense_Matrix current,
Dense_Matrix previous 
)

This routine sets up memory for the next Dense_Matrix we wish to use.

It looks at the previous Dense_Matrix we used, and increments fields

INPUT: previous -- the last Dense_Matrix we used.

OUTPUT: current -- the Dense_Matrix we wish to use next. We align current->matrix to the first space not used by previous->matrix, and set current->max_size to account for the amount used in previous.

Here is the caller graph for this function:

Dense_Matrix init_dmat_memory ( unsigned int  n)

This routine gets a large amount of memory for Dense_Matrix's, and gives it to a single Dense_Matrix to hold. This special Dense_Matrix acts as a pointer to this block of memory, and also keeps track of how large this memory is.

INPUT: n -- the amount of memory to get

OUPUT: returns a Dense_Matrix with

  • .max_size=n
  • .n_row=0
  • .n_col=0
  • .matrix pointing to memory for n REAL's

Here is the caller graph for this function:

void load_bin_dmat ( Dense_Matrix x,
FILE *  in 
)

This routine loads a Dense_Matrix from a file in binary format, as written by dump_bin_dmat.

INPUTS:

  • x -- the Dense_Matrix to be filled in. Should be initialized with
    • .max_size indicating the amount of memory available
    • .matrix pointing to max_size REALs
  • in -- A pointer to the file to read from. Setting this to stdin makes it read from the screen. If in==NULL we use stdin. The reading mode ("rb") is determined outside of this routine.

OUTPUT: x -- is filled in.

Here is the caller graph for this function: