42#if defined __cplusplus
95 n *
sizeof(
double ), 0,
"data" ) ) == NULL )
return( NULL );
96 newMatrix->rows = oldMatrix->
rows;
97 newMatrix->columns = oldMatrix->
columns;
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;
117 xData_Int i, j, row, start, end, rows, columns, status = 0;
119 const char *s, *size;
128 smrUser, __FILE__, __LINE__, 1,
"xData missing \"size\" attribute" ) );
130 while( isspace( *e ) ) e++;
132 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"matrix size attribute missing \",\" separator" );
135 s = (
const char *) ++e;
138 rows * columns *
sizeof(
double ), 0,
"xDT->data" ) ) == NULL )
return( 1 );
145 for( i = 0, s = text; i < xDT->
length; i++ ) {
147 if( ( row < 0 ) || ( row >= rows ) ) {
149 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"row = %lld out-of-range (valid range is 0 <= row <= %lld)", row, rows );
153 if( ( start < 0 ) || ( start > columns ) ) {
155 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"start = %lld out-of-range (valid range is 0 <= start <= %lld)", start, columns );
159 if( ( end < start ) || ( end > columns ) ) {
161 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"end = %lld out-of-range (valid range is %lld <= end <= %lld)", end, start, columns );
167 p = &(matrix->
values[row * columns]);
168 for( j = 0; j < start; j++ ) *(p++) = 0.;
169 for( s = e; j < end; j++, p++, s = e ) {
172 if( status != 0 )
break;
173 for( ; j < columns; j++ ) *(p++) = 0.;
176 while( isspace( *e ) ) e++;
178 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"matrix contains extra data = %s", e );
182 if( status != 0 ) release( smr, xDT );
191 xData_Int i,
n = 1, start, end, iRow, iColumn;
196 for( iRow = 0; iRow < matrix->rows; iRow++ ) {
198 for( iColumn = 0; iColumn < matrix->
columns; iColumn++ )
if( row[iColumn] != 0. )
break;
200 for( end = iColumn; iColumn < matrix->
columns; iColumn++ )
if( row[iColumn] != 0. ) end = iColumn + 1;
201 if( start < end )
n += 10 * 3 + 17 * ( end - start + 1 );
203 if( ( str = (
char *)
xData_malloc2( NULL, n, 0,
"str" ) ) == NULL )
return( NULL );
204 for( iRow = 0, p = str; iRow < matrix->
rows; iRow++ ) {
206 for( iColumn = 0; iColumn < matrix->
columns; iColumn++ )
if( row[iColumn] != 0. )
break;
208 for( end = iColumn; iColumn < matrix->
columns; iColumn++ )
if( row[iColumn] != 0. ) end = iColumn + 1;
210 sprintf( p,
"%3d %3d %3d", iRow, start, end );
212 for( i = start; i < end; i++, p += 17 ) sprintf( p,
" %16.9e", row[i] );
237 if( ( index < 0 ) || ( index >= xDT->
length ) ) {
239 "index = %lld out of range (valid range 0 <= index < %lld)", index, xDT->
length );
249#if defined __cplusplus
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
enum xData_xDataType status
xDT_releaseFunction release
xDT_toStringFunction toString
xDT_toDataFunction toData
xData_matrix_rowStartEnd * rowStartEnds
xData_matrix * xData_matrix_copyData(statusMessageReporting *smr, xData_element *element)
void * xData_free(statusMessageReporting *smr, void *p)
int xData_stringTo_double(statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e)
void * xData_get_smrUserInterfaceFromElement(xData_element *element)
int xData_isElement_matrix(statusMessageReporting *smr, xData_element *element, int setMsg)
int getRowStartEndAtIndex(statusMessageReporting *smr, xDataType *xDT, xData_Int index, xData_Int *row, xData_Int *start, xData_Int *end)
int xData_is_xDataType(statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
int xData_init_matrix(statusMessageReporting *smr, xData_element *element)
char const *const xData_matrix_ID
int xData_stringTo_xData_Int(statusMessageReporting *smr, void *smrUserInterface, char const *c, xData_Int *value, char const *endings, char **e)
int xData_matrix_free_copyData(statusMessageReporting *smr, void *data)
int xData_is_matrix(statusMessageReporting *smr, xDataType *xDT, int setMsg)
int xData_xDataTypeConvertAttributes(statusMessageReporting *smr, xData_element *element)
int xData_setMessageError_ReturnInt(int value, statusMessageReporting *smr, void *userData, const char *file, int line, int code, const char *fmt,...)
char * xData_getAttributesValue(xData_attributionList *attributes, const char *name)
#define xData_malloc2(smr, size, zero, forItem)