#include "sciMatrix.h"#include "string.h"#include "MALLOC.h"#include <stdlib.h>Include dependency graph for sciMatrix.c:

Go to the source code of this file.
Functions | |
| sciMatrix * | emptyMatrix (void) |
| sciMatrix * | newMatrix (int nbRow, int nbCol) |
| sciMatrix * | newCompleteMatrix (void **dataMat, int nbRow, int nbCol) |
| void | deleteMatrix (sciMatrix *mat) |
| void | desallocateMatrix (sciMatrix *mat) |
| void * | getMatElement (const sciMatrix *mat, int row, int col) |
| void | setMatElement (sciMatrix *mat, int row, int col, void *newValue) |
| void | changeMatElement (sciMatrix *mat, int row, int col, void *newValue) |
| void | copyMatElement (sciMatrix *mat, int row, int col, const void *copyValue, int valueSize) |
| int | getMatNbRow (const sciMatrix *mat) |
| int | getMatNbCol (const sciMatrix *mat) |
| void ** | getMatData (const sciMatrix *mat) |
desalocate the (row,col) element and put a new one.
| newValue | the new value which will be inserted directly in the matrix (no copy). |
Definition at line 96 of file sciMatrix.c.
References FREE, mat, and NULL.
Referenced by copyMatElement().
00097 { 00098 if ( mat->data[row + col * mat->nbRow] != NULL ) 00099 { 00100 FREE( mat->data[row + col * mat->nbRow] ) ; 00101 } 00102 mat->data[row + col * mat->nbRow] = newValue ; 00103 }
Here is the caller graph for this function:

desalocate the (row,col) current element (i,j) and copy the new one. The size of the element must be given in order to allocate memory.
| copyValue | copied value. | |
| valueSize | size of the data inserted in the matrix (ex: sizeof(double) ). |
Definition at line 105 of file sciMatrix.c.
References changeMatElement(), MALLOC, mat, and memcpy().
Referenced by copyVect2dMatElement(), and copyVect2iMatElement().
00110 { 00111 /* copy the value */ 00112 void * newValue = MALLOC( valueSize ) ; 00113 memcpy( newValue, copyValue, valueSize ) ; 00114 00115 /* change the current one */ 00116 changeMatElement( mat, row, col, newValue ) ; 00117 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void deleteMatrix | ( | sciMatrix * | mat | ) |
delete the structure and data
Definition at line 59 of file sciMatrix.c.
References FREE, i, mat, and NULL.
Referenced by ConstructLegend(), ConstructText(), ConstructTitle(), deallocateText(), DestroyLegend(), DestroyText(), DestroyTitle(), DestroyUimenu(), drawTextEntity(), get_tics_labels_property(), sciSetStrings(), and sciSetText().
00060 { 00061 int i ; 00062 for ( i = 0 ; i < mat->nbRow * mat->nbCol ; i++ ) 00063 { 00064 FREE( mat->data[i] ) ; 00065 mat->data[i] = NULL ; 00066 } 00067 FREE( mat->data ) ; 00068 mat->data = NULL ; 00069 00070 mat->nbCol = 0 ; 00071 mat->nbRow = 0 ; 00072 00073 FREE( mat ) ; 00074 }
Here is the caller graph for this function:

| void desallocateMatrix | ( | sciMatrix * | mat | ) |
delete only the structure, not the data (use with caution).
Definition at line 76 of file sciMatrix.c.
References FREE, mat, and NULL.
Referenced by getStringBox().
00077 { 00078 mat->nbCol = 0 ; 00079 mat->nbRow = 0 ; 00080 mat->data = NULL ; 00081 FREE( mat ) ; 00082 }
Here is the caller graph for this function:

| sciMatrix* emptyMatrix | ( | void | ) |
allocate a matrix with no elements (nbrow = nbcol = 0)
Definition at line 16 of file sciMatrix.c.
References sciMatrix::data, MALLOC, sciMatrix::nbCol, sciMatrix::nbRow, and NULL.
Referenced by newCompleteMatrix(), and newMatrix().
00017 { 00018 sciMatrix * newMat ; 00019 newMat = MALLOC( sizeof(sciMatrix) ) ; 00020 newMat->data = NULL ; 00021 newMat->nbCol = 0 ; 00022 newMat->nbRow = 0 ; 00023 00024 return newMat ; 00025 }
Here is the caller graph for this function:

| void** getMatData | ( | const sciMatrix * | mat | ) |
get the pointer on the array of data. May be used for faster access to the data.
Definition at line 123 of file sciMatrix.c.
References mat.
Referenced by getStrMatData().
00123 { return mat->data ; }
Here is the caller graph for this function:

retrieve the element (row,col) of the matrix.
Definition at line 84 of file sciMatrix.c.
References mat.
Referenced by getStrMatElement(), getVect2dMatElement(), and getVect2iMatElement().
00085 { 00086 /* the matrix is stored by column like in scilab */ 00087 00088 return mat->data[row + col * mat->nbRow] ; 00089 }
Here is the caller graph for this function:

Definition at line 121 of file sciMatrix.c.
References mat.
Referenced by computeSuitableFont(), drawStringsInPosition(), getStringsRect(), and sciGetTextSize().
00121 { return mat->nbCol ; }
Here is the caller graph for this function:

Definition at line 119 of file sciMatrix.c.
References mat.
Referenced by computeSuitableFont(), drawStringsInPosition(), getStringsRect(), and sciGetTextSize().
00119 { return mat->nbRow ; }
Here is the caller graph for this function:

create a nbRow x nbCol matrix which data are dataMat (directly, no copy).
Definition at line 47 of file sciMatrix.c.
References sciMatrix::data, emptyMatrix(), sciMatrix::nbCol, and sciMatrix::nbRow.
Referenced by getStringBox().
00048 { 00049 /* create the matrix */ 00050 sciMatrix * newMat = emptyMatrix() ; 00051 00052 newMat->data = dataMat ; 00053 newMat->nbRow = nbRow ; 00054 newMat->nbCol = nbCol ; 00055 00056 return newMat ; 00057 }
Here is the call graph for this function:

Here is the caller graph for this function:

create a nbRow x nbCol matrix of NULL pointers.
Definition at line 27 of file sciMatrix.c.
References sciMatrix::data, emptyMatrix(), i, MALLOC, sciMatrix::nbCol, sciMatrix::nbRow, and NULL.
Referenced by computeDefaultTicsLabels(), drawTextEntity(), and newFullStringMatrix().
00028 { 00029 int i ; 00030 /* create the matrix */ 00031 sciMatrix * newMat = emptyMatrix() ; 00032 00033 /* allocate the data */ 00034 newMat->data = MALLOC( (nbRow * nbCol)*sizeof(void *) ) ; 00035 newMat->nbRow = nbRow ; 00036 newMat->nbCol = nbCol ; 00037 00038 /* initialize to NULL */ 00039 for ( i = 0 ; i < nbRow * nbCol ; i++ ) 00040 { 00041 newMat->data[i] = NULL ; 00042 } 00043 00044 return newMat ; 00045 }
Here is the call graph for this function:

Here is the caller graph for this function:

set an element of the matrix to a new value but does not desalocate the previous if one exists.
| newValue | the new value which will be inserted directly in the matrix (no copy). |
Definition at line 91 of file sciMatrix.c.
References mat.
1.5.1