41 #if defined __cplusplus
48 static int toData( statusMessageReporting *smr, xDataType *xDT, xData_attributionList *attributes,
const char *text );
49 static char *
toString( statusMessageReporting *smr, xDataType *xDT );
50 static int release( statusMessageReporting *smr, xDataType *xDT );
57 xDataType *xDT = &(element->xDataTypeInfo);
59 xDT->status = xData_xDataType_Ok;
60 xDT->typeString = xData_twod_xindex_y_ID;
61 xDT->element = element;
86 static int toData( statusMessageReporting *smr, xDataType *xDT, xData_attributionList *,
const char *text ) {
88 xData_Int i, status = 0;
96 if( ( xDT->data = xData_malloc2( smr, 2 * xDT->length *
sizeof( xData_2d_xindex_y ), 0,
"data" ) ) == NULL )
return( 1 );
97 for( i = 0, s = text, p = (xData_2d_xindex_y *) xDT->data; i < xDT->length; i++, p++, s = e ) {
103 while( isspace( *e ) ) e++;
105 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"2d_xindex_y contains extra data = %s", e );
109 if( status != 0 )
release( smr, xDT );
116 static char *
toString( statusMessageReporting *, xDataType *xDT ) {
118 xData_Int i,
n = xDT->length, recordSize = 5 + 16 + 1, indexMax = 9;
120 char *str, *p, fmt[32] =
" %99d %15.7e\n";
121 xData_2d_xindex_y *data = (xData_2d_xindex_y *) xDT->data;
124 for( i = 0; i <
n; i++, data++ ) {
125 while( ( data->index > indexMax ) && ( indexMax > 0 ) ) {
126 indexMax = 10 * indexMax + 9;
131 sprintf( fmt,
" %%%dld %%15.7e\n", iFmt );
132 if( ( str = (
char *) malloc( recordSize * ( n + 1 ) ) ) == NULL )
return( NULL );
133 for( i = 0, p = str, data = (xData_2d_xindex_y *) xDT->data; i < n; i++, p += recordSize, data++ ) {
134 sprintf( p, fmt, data->index, data->value );
142 static int release( statusMessageReporting *smr, xDataType *xDT ) {
144 if( xDT->data != NULL ) xDT->data =
xData_free( smr, xDT->data );
145 return( xDT->status = xData_xDataType_Ok );
154 xDataType *xDT = &(element->xDataTypeInfo);
155 xData_Int i, index = xDT->start, *values;
156 xData_2d_xindex_y *data = (xData_2d_xindex_y *) xDT->data;
158 if( xDT->length == 0 )
return( NULL );
160 if( ( values = (xData_Int*) xData_malloc2( smr, xDT->length *
sizeof( xData_Int ), 0,
"values" ) ) == NULL )
return( NULL );
161 for( i = 0; i < xDT->length; i++ ) {
163 index += data[i].index;
182 xDataType *xDT = &(element->xDataTypeInfo);
183 xData_Int i, index = xDT->start;
184 double *values = NULL, *p;
185 xData_2d_xindex_y *data = (xData_2d_xindex_y *) xDT->data;
187 if( xDT->length == 0 )
return( NULL );
189 if( ( values = (
double*) xData_malloc2( smr, 2 * xDT->length *
sizeof(
double ), 0,
"values" ) ) == NULL )
return( NULL );
191 for( i = 0; i < xDT->length; i++, p++ ) {
192 index += data[i].index;
228 xDataType *xDT = &(element->xDataTypeInfo);
229 xData_Int i, j, index = xDT->start, length = xDT->end - xDT->start;
230 double x1, x2, *x, y1, y2, *values = NULL, *p;
231 xData_2d_xindex_y *data = (xData_2d_xindex_y *) xDT->data;
233 if( xDT->length == 0 )
return( NULL );
235 if( ( values = (
double*) xData_malloc2( smr, size * length *
sizeof(
double ), 0,
"values" ) ) == NULL )
return( NULL );
237 x = &(Xs[xDT->start]);
240 for( i = 0; i < xDT->length; i++, x++, p++ ) {
241 index += data[i].index;
246 for( j = data[i].index; j > 1; j--, x++, p++ ) {
251 *p = ( y1 * ( x2 - *x ) + y2 * ( *x - x1 ) ) / ( x2 - x1 );
253 if( size == 2 ) *(p++) = *x;
259 #if defined __cplusplus
static double * xData_2d_xindex_y_toFilled(statusMessageReporting *smr, xData_element *element, double *Xs, int size)
int xData_2d_xindex_y_free_toFilledYs(statusMessageReporting *smr, void *data)
double * xData_2d_xindex_y_toFilledXYs(statusMessageReporting *smr, xData_element *element, double *Xs)
int xData_stringTo_xData_Int(statusMessageReporting *smr, void *smrUserInterface, char const *c, xData_Int *value, char const *endings, char **e)
int xData_xDataTypeConvertAttributes(statusMessageReporting *smr, xData_element *element)
int xData_isElement_2d_xindex_y(statusMessageReporting *smr, xData_element *element, int setMsg)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
static char * toString(statusMessageReporting *smr, xDataType *xDT)
int xData_init_2d_xindex_y(statusMessageReporting *smr, xData_element *element)
xData_Int * xData_2d_xindex_y_rawIndices(statusMessageReporting *smr, xData_element *element)
double * xData_2d_xindex_y_toFilledYs(statusMessageReporting *smr, xData_element *element, double *Xs)
double * xData_2d_xindex_y_toXYs(statusMessageReporting *smr, xData_element *element, double *Xs)
int xData_2d_xindex_y_free_rawIndices(statusMessageReporting *smr, void *data)
int xData_is_xDataType(statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
void * xData_free(statusMessageReporting *, 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)
static int release(statusMessageReporting *smr, xDataType *xDT)
int xData_is_2d_xindex_y(statusMessageReporting *smr, xDataType *xDT, int setMsg)
static int toData(statusMessageReporting *smr, xDataType *xDT, xData_attributionList *attributes, const char *text)
int xData_setMessageError_ReturnInt(int value, statusMessageReporting *smr, void *userInterface, const char *packageName, int lineNumber, int code, const char *fmt,...)