sundials_dense.c

Go to the documentation of this file.
00001 /*
00002  * -----------------------------------------------------------------
00003  * $Revision: 1.3 $
00004  * $Date: 2006/10/19 21:19:39 $
00005  * -----------------------------------------------------------------
00006  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
00007  *                Radu Serban @ LLNL
00008  * -----------------------------------------------------------------
00009  * Copyright (c) 2002, The Regents of the University of California.
00010  * Produced at the Lawrence Livermore National Laboratory.
00011  * All rights reserved.
00012  * For details, see the LICENSE file.
00013  * -----------------------------------------------------------------
00014  * This is the implementation file for a generic package of dense
00015  * matrix operations.
00016  * -----------------------------------------------------------------
00017  */ 
00018 
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 
00022 #include "sundials_dense.h"
00023 #include "sundials_math.h"
00024 
00025 #define ZERO RCONST(0.0)
00026 #define ONE  RCONST(1.0)
00027 
00028 /* Implementation */
00029 
00030 DenseMat DenseAllocMat(long int M, long int N)
00031 {
00032   DenseMat A;
00033 
00034   /* Note that M and N are tested in denalloc */
00035 
00036   A = NULL;
00037   A = (DenseMat) malloc(sizeof *A);
00038   if (A==NULL) return (NULL);
00039   
00040   A->data = NULL;
00041   A->data = denalloc(M, N);
00042   if (A->data == NULL) {
00043     free(A); A = NULL;
00044     return(NULL);
00045   }
00046 
00047   A->M = M;
00048   A->N = N;
00049 
00050   return(A);
00051 }
00052 
00053 long int *DenseAllocPiv(long int N)
00054 {
00055   return(denallocpiv(N));
00056 }
00057 
00058 long int DenseGETRF(DenseMat A, long int *p)
00059 {
00060   return(denGETRF(A->data, A->M, A->N, p));
00061 }
00062 
00063 void DenseGETRS(DenseMat A, long int *p, realtype *b)
00064 {
00065   denGETRS(A->data, A->N, p, b);
00066 }
00067 
00068 void DenseZero(DenseMat A)
00069 {
00070   denzero(A->data, A->M, A->N);
00071 }
00072 
00073 void DenseCopy(DenseMat A, DenseMat B)
00074 {
00075   dencopy(A->data, B->data, A->M, A->N);
00076 }
00077 
00078 void DenseScale(realtype c, DenseMat A)
00079 {
00080   denscale(c, A->data, A->M, A->N);
00081 }
00082 
00083 void DenseAddI(DenseMat A)
00084 {
00085   denaddI(A->data, A->N);
00086 }
00087 
00088 void DenseFreeMat(DenseMat A)
00089 {
00090   denfree(A->data);
00091   free(A); A = NULL;
00092 }
00093 
00094 void DenseFreePiv(long int *p)
00095 {  
00096   denfreepiv(p);
00097 }
00098 
00099 void DensePrint(DenseMat A)
00100 {
00101   denprint(A->data, A->M, A->N);
00102 }

Generated on Tue Sep 9 17:48:33 2008 for Scilab [trunk] by  doxygen 1.5.5