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

Linux Cross Reference
Tina4/src/math/matrix/mat_build.c

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

  1 /**@(#)Build Matrices of various types and shapes around already allocated arrays
  2  */
  3 
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 
  8 Matrix *matrix_build(int m, int n, Matrix_shape shape, Vartype vtype, void *el)
  9 {
 10     Matrix *mat;
 11 
 12     if (m < 0 || n < 0)
 13     {
 14         error("matrix_build: bad size", non_fatal);
 15         return (NULL);
 16     }
 17     if (m == 0 || n == 0)
 18     {
 19         error("matrix_build: zero size", warning);
 20         return (NULL);
 21     }
 22     if (el == NULL)
 23     {
 24         error("matrix_build: null array", non_fatal);
 25         return (NULL);
 26     }
 27     mat = ts_ralloc(Matrix);
 28     mat->m = m;
 29     mat->n = n;
 30     mat->shape = shape;
 31     mat->vtype = vtype;
 32     switch (mat->vtype)
 33     {
 34     case int_v:
 35         mat->el.int_v = (int **) el;
 36         break;
 37     case float_v:
 38         mat->el.float_v = (float **) el;
 39         break;
 40     case double_v:
 41         mat->el.double_v = (double **) el;
 42         break;
 43     }
 44     return (mat);
 45 }
 46 
 47 
 48 Matrix  *matrix_expand(Matrix *mat, int m, int n)
 49 {
 50   Matrix  *matrix_alloc();
 51   Matrix  *copy;
 52 
 53   copy = matrix_alloc(m, n, mat->shape, mat->vtype);
 54   matrix_copy_inplace(mat, copy);
 55   matrix_free(mat);
 56 
 57   return(copy);
 58 }
 59 

~ [ 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.