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