Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xData_matrix.cc File Reference
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include "xData.h"

Go to the source code of this file.

Functions

int xData_init_matrix (statusMessageReporting *smr, xData_element *element)
 
int xData_is_matrix (statusMessageReporting *smr, xDataType *xDT, int setMsg)
 
int xData_isElement_matrix (statusMessageReporting *smr, xData_element *element, int setMsg)
 
xData_matrixxData_matrix_copyData (statusMessageReporting *smr, xData_element *element)
 
int xData_matrix_free_copyData (statusMessageReporting *smr, void *data)
 
int getRowStartEndAtIndex (statusMessageReporting *smr, xDataType *xDT, xData_Int index, xData_Int *row, xData_Int *start, xData_Int *end)
 

Function Documentation

◆ getRowStartEndAtIndex()

int getRowStartEndAtIndex ( statusMessageReporting smr,
xDataType xDT,
xData_Int  index,
xData_Int row,
xData_Int start,
xData_Int end 
)

Definition at line 231 of file xData_matrix.cc.

231 {
232
233 int status = 0;
234 xData_matrix *matrix = (xData_matrix *) xDT->data;
235
236 if( !xData_is_matrix( smr, xDT, 1 ) ) return( 1 );
237 if( ( index < 0 ) || ( index >= xDT->length ) ) {
238 smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( xDT->element ), __FILE__, __LINE__, 1,
239 "index = %lld out of range (valid range 0 <= index < %lld)", index, xDT->length );
240 status = 1; }
241 else {
242 *row = matrix->rowStartEnds[index].row;
243 *start = matrix->rowStartEnds[index].start;
244 *end = matrix->rowStartEnds[index].end;
245 }
246 return( status );
247}
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
xData_Int length
Definition: xData.h:162
xData_element * element
Definition: xData.h:157
void * data
Definition: xData.h:163
xData_matrix_rowStartEnd * rowStartEnds
Definition: xData.h:112
void * xData_get_smrUserInterfaceFromElement(xData_element *element)
Definition: xData.cc:952
int xData_is_matrix(statusMessageReporting *smr, xDataType *xDT, int setMsg)
Definition: xData_matrix.cc:71

◆ xData_init_matrix()

int xData_init_matrix ( statusMessageReporting smr,
xData_element element 
)

Definition at line 55 of file xData_matrix.cc.

55 {
56
57 xDataType *xDT = &(element->xDataTypeInfo);
58
61 xDT->element = element;
62 xDT->toData = toData;
63 xDT->toString = toString;
64 xDT->release = release;
65 xDT->data = NULL;
66 return( xData_xDataTypeConvertAttributes( smr, element ) );
67}
enum xData_xDataType status
Definition: xData.h:155
xDT_releaseFunction release
Definition: xData.h:160
const char * typeString
Definition: xData.h:156
xDT_toStringFunction toString
Definition: xData.h:159
xDT_toDataFunction toData
Definition: xData.h:158
xDataType xDataTypeInfo
Definition: xData.h:187
char const *const xData_matrix_ID
Definition: xData.h:75
int xData_xDataTypeConvertAttributes(statusMessageReporting *smr, xData_element *element)
Definition: xData.cc:668
@ xData_xDataType_Ok
Definition: xData.h:81

◆ xData_is_matrix()

int xData_is_matrix ( statusMessageReporting smr,
xDataType xDT,
int  setMsg 
)

Definition at line 71 of file xData_matrix.cc.

71 {
72
73 return( xData_is_xDataType( smr, xDT, xData_matrix_ID, setMsg ) );
74}
int xData_is_xDataType(statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
Definition: xData.cc:900

Referenced by getRowStartEndAtIndex(), and xData_isElement_matrix().

◆ xData_isElement_matrix()

int xData_isElement_matrix ( statusMessageReporting smr,
xData_element element,
int  setMsg 
)

Definition at line 78 of file xData_matrix.cc.

78 {
79
80 return( xData_is_matrix( smr, &(element->xDataTypeInfo), setMsg ) );
81}

Referenced by xData_matrix_copyData().

◆ xData_matrix_copyData()

xData_matrix * xData_matrix_copyData ( statusMessageReporting smr,
xData_element element 
)

Definition at line 85 of file xData_matrix.cc.

85 {
86
87 xData_Int i, n;
88 xDataType *xDT = &(element->xDataTypeInfo);
89 xData_matrix *oldMatrix = (xData_matrix *) xDT->data, *newMatrix;
90 double *oldP, *newP;
91
92 if( !xData_isElement_matrix( smr, element, 1 ) ) return( NULL );
93 n = oldMatrix->rows * oldMatrix->columns;
94 if( ( newMatrix = (xData_matrix *) xData_malloc2( smr, sizeof( xData_matrix ) + xDT->length * sizeof( xData_matrix_rowStartEnd ) +
95 n * sizeof( double ), 0, "data" ) ) == NULL ) return( NULL );
96 newMatrix->rows = oldMatrix->rows;
97 newMatrix->columns = oldMatrix->columns;
98 newMatrix->rowStartEnds = (xData_matrix_rowStartEnd *) &(newMatrix[1]);
99 newMatrix->values = (double *) &(newMatrix->rowStartEnds[xDT->length]);
100 for( i = 0; i < xDT->length; i++ ) newMatrix->rowStartEnds[i] = oldMatrix->rowStartEnds[i];
101 for( i = 0, oldP = oldMatrix->values, newP = newMatrix->values; i < n; i++, oldP++, newP++ ) *newP = *oldP;
102 return( newMatrix );
103}
xData_Int columns
Definition: xData.h:111
double * values
Definition: xData.h:113
xData_Int rows
Definition: xData.h:111
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313
int xData_Int
Definition: xData.h:50
int xData_isElement_matrix(statusMessageReporting *smr, xData_element *element, int setMsg)
Definition: xData_matrix.cc:78

◆ xData_matrix_free_copyData()

int xData_matrix_free_copyData ( statusMessageReporting smr,
void *  data 
)

Definition at line 107 of file xData_matrix.cc.

107 {
108
109 xData_free( smr, data );
110 return( 0 );
111}
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89