~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina5/tina-libs/tina/math/mathMatr_free.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  *
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  *
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/math/mathMatr_free.c,v $
 37  * Date    :  $Date: 2005/01/23 19:10:21 $
 38  * Version :  $Revision: 1.5 $
 39  * CVS Id  :  $Id: mathMatr_free.c,v 1.5 2005/01/23 19:10:21 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : Matrix freeing (various types and shapes)
 44  *
 45  *********
 46 */
 47 /** 
 48  *  @file
 49  *  @brief  Matrix freeing functions according to type and shape.       
 50  *
 51  *
 52  * 
 53 */
 54 
 55 #include "mathMatr_free.h"
 56 
 57 #if HAVE_CONFIG_H
 58 #include <config.h>
 59 #endif
 60 
 61 
 62 #include <math.h>
 63 #include <stdio.h>
 64 #include <tina/sys/sysDef.h>
 65 #include <tina/sys/sysPro.h>
 66 
 67 
 68 void            matrix_free(Matrix * mat)
 69 {
 70         if (mat == NULL)
 71                 return;
 72         switch (mat->vtype)
 73         {
 74         case char_v:
 75         case uchar_v:
 76                 cmatrix_free((Matrix *) mat);
 77                 break;
 78         case short_v:
 79         case ushort_v:
 80                 smatrix_free((Matrix *) mat);
 81                 break;
 82         case int_v:
 83         case uint_v:
 84                 imatrix_free((Matrix *) mat);
 85                 break;
 86         case float_v:
 87                 fmatrix_free(mat);
 88                 break;
 89         case double_v:
 90                 dmatrix_free(mat);
 91                 break;
 92         case complex_v:
 93                 zmatrix_free(mat);
 94                 break;
 95         case ptr_v:
 96                 pmatrix_free(mat);
 97                 break;
 98         default:
 99                 error("matrix_free: unsupported type", non_fatal);
100                 break;
101         }
102 }
103 
104 void            cmatrix_free(Matrix * mat)
105 {
106         switch (mat->shape)
107         {
108                 case matrix_full:
109                 carray_free(mat->el.char_v, 0, 0, mat->m, mat->n);
110                 break;
111         case matrix_lower:
112         case matrix_symmetric:
113                 clower_free(mat->el.char_v, 0, mat->m);
114                 break;
115         case matrix_upper:
116                 cupper_free(mat->el.char_v, 0, mat->m);
117                 break;
118         }
119         rfree((void *) mat);
120 }
121 
122 void            smatrix_free(Matrix * mat)
123 {
124         switch (mat->shape)
125         {
126                 case matrix_full:
127                 sarray_free(mat->el.short_v, 0, 0, mat->m, mat->n);
128                 break;
129         case matrix_lower:
130         case matrix_symmetric:
131                 slower_free(mat->el.short_v, 0, mat->m);
132                 break;
133         case matrix_upper:
134                 supper_free(mat->el.short_v, 0, mat->m);
135                 break;
136         }
137         rfree((void *) mat);
138 }
139 
140 void            imatrix_free(Matrix * mat)
141 {
142         switch (mat->shape)
143         {
144                 case matrix_full:
145                 iarray_free(mat->el.int_v, 0, 0, mat->m, mat->n);
146                 break;
147         case matrix_lower:
148         case matrix_symmetric:
149                 ilower_free(mat->el.int_v, 0, mat->m);
150                 break;
151         case matrix_upper:
152                 iupper_free(mat->el.int_v, 0, mat->m);
153                 break;
154         }
155         rfree((void *) mat);
156 }
157 
158 void            fmatrix_free(Matrix * mat)
159 {
160         switch (mat->shape)
161         {
162                 case matrix_full:
163                 farray_free(mat->el.float_v, 0, 0, mat->m, mat->n);
164                 break;
165         case matrix_lower:
166         case matrix_symmetric:
167                 flower_free(mat->el.float_v, 0, mat->m);
168                 break;
169         case matrix_upper:
170                 fupper_free(mat->el.float_v, 0, mat->m);
171                 break;
172         }
173         rfree((void *) mat);
174 }
175 
176 void            dmatrix_free(Matrix * mat)
177 {
178         switch (mat->shape)
179         {
180                 case matrix_full:
181                 darray_free(mat->el.double_v, 0, 0, mat->m, mat->n);
182                 break;
183         case matrix_lower:
184         case matrix_symmetric:
185                 dlower_free(mat->el.double_v, 0, mat->m);
186                 break;
187         case matrix_upper:
188                 dupper_free(mat->el.double_v, 0, mat->m);
189                 break;
190         }
191         rfree((void *) mat);
192 }
193 
194 void            pmatrix_free(Matrix * mat)
195 {
196         switch (mat->shape)
197         {
198                 case matrix_full:
199                 parray_free(mat->el.ptr_v, 0, 0, mat->m, mat->n);
200                 break;
201         case matrix_lower:
202         case matrix_symmetric:
203                 plower_free(mat->el.ptr_v, 0, mat->m);
204                 break;
205         case matrix_upper:
206                 pupper_free(mat->el.ptr_v, 0, mat->m);
207                 break;
208         }
209         rfree((void *) mat);
210 }
211 
212 void            zmatrix_free(Matrix * mat)
213 {
214         switch (mat->shape)
215         {
216                 case matrix_full:
217                 zarray_free(mat->el.complex_v, 0, 0, mat->m, mat->n);
218                 break;
219         case matrix_lower:
220         case matrix_symmetric:
221                 zlower_free(mat->el.complex_v, 0, mat->m);
222                 break;
223         case matrix_upper:
224                 zupper_free(mat->el.complex_v, 0, mat->m);
225                 break;
226         }
227         rfree((void *) mat);
228 }
229 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.