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

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

#include "libftsh.h"

Defines

#define ENTEREXIT   0

Functions

Banded_Matrix init_bdmat_memory (int max_size, int max_rows, int max_bands)
void give_bdmat_memory (Banded_Matrix *current, Banded_Matrix *previous)
void free_bdmat_memory (Banded_Matrix *in)
void bdmat_copy (Banded_Matrix *out, Banded_Matrix *in)
void dump_bin_bdmat (Banded_Matrix *x, FILE *out)
void load_bin_bdmat (Banded_Matrix *x, FILE *in)

Detailed Description

Contains simple functions based on the Banded_Matrix struct.

Summary:


Function Documentation

void bdmat_copy ( Banded_Matrix out,
Banded_Matrix in 
)

This routine copies a Banded_Matrix.

INPUTS: in -- the Banded_Matrix to copy

OUTPUT: out -- the values of in are copied to out Should be initialized as follows

  • .max_rows is the amount of row memory available
  • .band_p points to .max_rows ints
  • .max_bands is the amount of band memory available
  • .band_list points to 3*.max_bands ints
  • .max_size is the amount of main memory available
  • .matrix points to .max_size REAL

Here is the caller graph for this function:

void dump_bin_bdmat ( Banded_Matrix x,
FILE *  out 
)

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

INPUTS:

  • x -- the Banded_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 Banded_Matrix by init_bdmat_memory.

INPUT: in -- the Banded_Matrix to free. it must have been initialized by init_bdmat_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_bdmat_memory ( Banded_Matrix current,
Banded_Matrix previous 
)

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

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

INPUT: previous -- the last Banded_Matrix we used

OUTPUT: current -- the Banded_Matrix we wish to use next

We set the .band_p, .band_list, and .matrix fields to the next available ints and REAL. .max_size, .max_rows, and .max_bands are set to account for the amount used in previous. also set: .non_zero=0; .n_row=-1 .n_col=0

Here is the caller graph for this function:

Banded_Matrix init_bdmat_memory ( int  max_size,
int  max_rows,
int  max_bands 
)

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

INPUT:

  • max_size -- the amount of memory to get for matrix
  • max_rows -- the amount of memory to get for band_p
  • max_bands -- (1/3) the amount of memory to get for band_list

OUPUT: returns a Banded_Matrix with

  • .max_size=max_size
  • .max_rows=max_rows+1
  • .max_bands=max_bands;
  • .non_zero=0;
  • .n_row=-1 This ruse allows give_bdmat_memory to pass along all the memory instead of losing one row
  • .n_col=0
  • .band_p pointing to max_rows+1 ints
  • .band_list pointing to 3*max_bands ints
  • .matrix pointing to max_size REALs

Here is the caller graph for this function:

void load_bin_bdmat ( Banded_Matrix x,
FILE *  in 
)

This routine boads a Banded_Matrix to a file in binary format, as written by dump_bin_bdmat

INPUTS:

  • x -- the Banded_Matrix. Should be initialized as follows
    • .max_rows is the amount of row memory available
    • .band_p points to .max_rows ints
    • .max_bands is the amount of band memory available
    • .band_list points to 3*.max_bands ints
    • .max_size is the amount of main memory available
    • .matrix points to .max_size REAL
  • 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: