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 );
56 xDataType *xDT = &(element->xDataTypeInfo);
58 xDT->status = xData_xDataType_Ok;
59 xDT->typeString = xData_twod_xShared_yHistogram_ID;
60 xDT->element = element;
87 xDataType *xDT = &(element->xDataTypeInfo);
89 double *p, *values, *d = (
double *) xDT->data;
91 *n = xDT->end - xDT->start;
92 if( xDT->length == 0 )
return( NULL );
93 if( *n == 0 )
return( NULL );
95 if(( values = (
double*) xData_malloc2( NULL, *n *
sizeof(
double ), 0,
"values" ) )) {
97 for( i = 0; i < *
n; i++, p++, d++ ) *p = *d;
113 static int toData( statusMessageReporting *smr, xDataType *xDT, xData_attributionList *,
const char *text ) {
115 xData_Int i,
n = xDT->end - xDT->start, status = 0;
123 if( ( xDT->data = xData_malloc2( smr, n *
sizeof(
double ), 0,
"data" ) ) == NULL )
return( 1 );
124 for( i = 0, s = text, p = (
double *) xDT->data; i < n; i++, p++, s = e ) {
128 while( isspace( *e ) ) e++;
130 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"text contains extra data = %s", e );
134 if( status != 0 )
release( smr, xDT );
141 static char *
toString( statusMessageReporting *, xDataType *xDT ) {
143 xData_Int i,
n = xDT->length, recordSize = 16 + 1;
144 char *str, *p, fmt[32] =
" %15.7e\n";
146 double *d = (
double*) xDT->data;
149 if( ( str = (
char *) malloc( recordSize * ( n + 1 ) ) ) == NULL )
return( NULL );
150 for( i = 0, p = str; i <
n; i++, p += recordSize, d++ ) sprintf( p, fmt, d ); *p = 0;
156 static int release( statusMessageReporting *smr, xDataType *xDT ) {
158 if( xDT->data != NULL ) xDT->data =
xData_free( smr, xDT->data );
159 return( xDT->status = xData_xDataType_Ok );
170 double *p, *values, *d = (
double*) xDT->data;
172 if( xDT->length == 0 )
return( NULL );
173 if( ( xDT->length + 1 ) != nXs )
return( NULL );
175 if( ( values = (
double*) xData_malloc2( NULL, 4 * xDT->length *
sizeof(
double ), 0,
"values" ) ) == NULL )
return( NULL );
177 for( i = 0; i < xDT->length; i++ ) {
183 p = &(values[4 * xDT->start + 1]);
184 for( i = xDT->start; i < xDT->end; i++, d++, p += 2 ) {
192 #if defined __cplusplus
int xData_xDataTypeConvertAttributes(statusMessageReporting *smr, xData_element *element)
int xData_isElement_2d_xShared_yHistogram(statusMessageReporting *smr, xData_element *element, int setMsg)
int xData_init_2d_xShared_yHistogram(statusMessageReporting *smr, xData_element *element)
double * xData_2d_xShared_yHistogram_copyData(statusMessageReporting *, xData_element *element, xData_Int *n)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
static int release(statusMessageReporting *smr, xDataType *xDT)
static int toData(statusMessageReporting *smr, xDataType *xDT, xData_attributionList *attributes, const char *text)
double * xData_2d_xShared_yHistogram_toFilledXYs(xDataType *xDT, xData_Int nXs, double *Xs)
int xData_is_xDataType(statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
int xData_2d_xShared_yHistogram_free_copyData(statusMessageReporting *smr, void *data)
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)
int xData_setMessageError_ReturnInt(int value, statusMessageReporting *smr, void *userInterface, const char *packageName, int lineNumber, int code, const char *fmt,...)
int xData_is_2d_xShared_yHistogram(statusMessageReporting *smr, xDataType *xDT, int setMsg)
static char * toString(statusMessageReporting *smr, xDataType *xDT)