Main Page | Data Structures | File List | Data Fields | Globals

doubleArray.c File Reference

Fault-tolerant structure to store one or more double values. More...

Go to the source code of this file.

Data Structures

struct  DoubleArray

Defines

#define DOUBLEARRAY_VERSION   "1.1.0"
#define DOUBLEARRAY_DATE   "23-Jun-2003"

Typedefs

typedef DoubleArrayDoubleArrayPtr
 A pointer to structure DoubleArray is assigned the name DoubleArrayPtr.


Functions

DoubleArrayPtr DoubleArray_create (const int numberOfElements)
 Creates a DoubleArray structure.

DoubleArrayPtr DoubleArray_createWithIdentifier (const int numberOfElements, const int identifier)
 Creates a DoubleArray structure with an identifier.

void DoubleArray_destroy (DoubleArrayPtr dAPtr)
 Destroys a structure DoubleArray.

void DoubleArray_display (void *dAPtr, FILE *outputStream)
 Displays a structure DoubleArray.

void DoubleArray_displayIntegers (const DoubleArrayPtr dAPtr, FILE *outputStream)
 Displays a structure DoubleArray.

DoubleArrayPtr DoubleArray_copy (const DoubleArrayPtr dAPtr)
 Copies a structure DoubleArray.

int DoubleArray_getIdentifier (const DoubleArrayPtr dAPtr)
 Returns the identifier of a structure DoubleArray.

int DoubleArray_getNumberOfElements (const DoubleArrayPtr dAPtr)
 Returns the number of elements of a structure DoubleArray.

void DoubleArray_setValue (const DoubleArrayPtr dAPtr, const int index, const double value)
 The element with index index of structure DoubleArray is assigned the value value.

double DoubleArray_getValue (const DoubleArrayPtr dAPtr, const int index)
 The value of the element with index index of structure DoubleArray is returned.

DoubleArrayPtr DoubleArray_calculateMeanAndSd (const DoubleArrayPtr dAPtr)
 The mean and standard deviation of the values contained in one DoubleArray is calculated.

int DoubleArray_lessThan (void *dAPtr1, void *dAPtr2)
 Evaluates if the first value of dAPtr1 is less than that of dAPtr2.


Detailed Description

Fault-tolerant structure to store one or more double values.

This structure provides a fault-tolerant way to store several double values. The individual values are accessed via their index starting from zero. Therefore, the index of the element with the highest index number is one less than numberOfElements. The memory allocation of the structure is managed via the DoubleArray_create and DoubleArray_destroy functions.

The structure is created with DoubleArray_create, destroyed with DoubleArray_destroy and displayed with DoubleArray_display. The structure could also be displayed with function DoubleArray_displayIntegers; the individual values of the elements are than treated as integers. It could be copied with the function DoubleArray_copy. The number of elements of a structure could be found out via DoubleArray_getNumberOfElements. Elements could be assigned values with DoubleArray_setValue and the value of an element could be obtained with DoubleArray_getValue.

If an element is accessed via DoubleArray_setValue or DoubleArray_getValue and the index is higher than numberOfElements - 1 (maximum index of this structure) the define IndexOutOfBoundsError is called and the program aborts.

Description of the members:

value - the double values of the structure
numberOfElements - number of elements in the structure

Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

05/20/2003 - Uli Fechner - added function DoubleArray_calculateMeanAndSd

05/22/2003 - Uli Fechner - added the member identifier und the functions DoubleArray_createWithIdentifier and DoubleArray_getIdentifier; adjusted the function DoubleArray_copy accordingly

05/23/2003 - Uli Fechner - SPECIAL MODIFICATION for the RankIt program: added function DoubleArray_lessThan

06/16/2003 - v1.0.1 - Uli Fechner - SPECIAL MODIFICATION for the RankIt program: several adjustments in function DoubleArray_calculateMeanAndSd

06/23/2003 - v1.1.0 - Uli Fechner - bugfix in function DoubleArray_calculateMeanAndSd \code

Definition in file doubleArray.c.


Define Documentation

#define DOUBLEARRAY_DATE   "23-Jun-2003"
 

Definition at line 3 of file doubleArray.c.

Referenced by displayVersionInformation().

#define DOUBLEARRAY_VERSION   "1.1.0"
 

Definition at line 2 of file doubleArray.c.

Referenced by displayVersionInformation().


Typedef Documentation

typedef DoubleArray* DoubleArrayPtr
 

A pointer to structure DoubleArray is assigned the name DoubleArrayPtr.

Definition at line 53 of file doubleArray.c.

Referenced by DoubleArray_calculateMeanAndSd(), DoubleArray_copy(), DoubleArray_create(), DoubleArray_createWithIdentifier(), getFileProperties(), and readDataFromStream().


Function Documentation

DoubleArrayPtr DoubleArray_calculateMeanAndSd const DoubleArrayPtr  dAPtr  ) 
 

The mean and standard deviation of the values contained in one DoubleArray is calculated.

The return value of this function is a DoubleArrayPtr. The corresponding DoubleArray contains two values:

  • 1st value - arithmetic mean
  • 2nd value - standard deviation
Parameters:
dAPtr pointer on the structure DoubleArray that contains the elements
Return values:
DoubleArrayPtr DoubleArray with two values: mean and standard deviation
Author:
Uli Fechner
Version:
05/20/2003 - Uli Fechner - initial release

05/23/2003 - Uli Fechner - SPECIAL MODIFICATION for the RankIt program (see remarks)

06/16/2003 - Uli Fechner - SPECIAL MODIFICATION for the RankIt program (see remarks)

06/23/2003 - Uli Fechner - IMPORTANT bugifx: the standard deviation for the active compounds was not calculated correctly

Definition at line 361 of file doubleArray.c.

References BOOLEAN_FALSE, BOOLEAN_TRUE, DoubleArray_create(), DoubleArray_getNumberOfElements(), DoubleArray_getValue(), DoubleArray_setValue(), and DoubleArrayPtr.

DoubleArrayPtr DoubleArray_copy const DoubleArrayPtr  dAPtr  ) 
 

Copies a structure DoubleArray.

A copy of the structure DoubleArray referred to by dAPtr is made. The copy lives in its own memory and contains all elements the template contains (sometimes called deepcopy).

Parameters:
dAPtr pointer on the structure DoubleArray that should be copied
Return values:
DoubleArrayPtr pointer on structure DoubleArray containing the copy
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

05/22/2003 - Uli Fechner - added the copying of the identifier

Definition at line 191 of file doubleArray.c.

References AbortProgram, DoubleArray_getIdentifier(), DoubleArray_getNumberOfElements(), DoubleArray_getValue(), DoubleArray_setValue(), DoubleArrayPtr, DoubleArray::identifier, MemoryError, DoubleArray::numberOfElements, and DoubleArray::value.

DoubleArrayPtr DoubleArray_create const int  numberOfElements  ) 
 

Creates a DoubleArray structure.

A DoubleArray structure is created. The number of elements of the structure is given as an argument and is not dynamic during the lifetime of a structure DoubleArray.

Parameters:
numberOfElements the number of elements of the newly created structure
Return values:
DoubleArrayPtr pointer on the newly created structure DoubleArray
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

Definition at line 95 of file doubleArray.c.

References DoubleArrayPtr, MemoryError, DoubleArray::numberOfElements, and DoubleArray::value.

Referenced by DoubleArray_calculateMeanAndSd(), and getFileProperties().

DoubleArrayPtr DoubleArray_createWithIdentifier const int  numberOfElements,
const int  identifier
 

Creates a DoubleArray structure with an identifier.

A DoubleArray structure is created. The number of elements of the structure is given as an argument and is not dynamic during the lifetime of a structure DoubleArray. The second argument is an integer that serves as a unique identifier of this DoubleArray. This function for the creation of a DoubleArray is useful, if the DoubleArray is part of an array of DoubleArrays.

Parameters:
numberOfElements the number of elements of the newly created structure
identifier integer that serves as a unique identifier
Return values:
DoubleArrayPtr pointer on the newly created structure DoubleArray
Author:
Uli Fechner
Version:
05/22/2003 - Uli Fechner - initial release

Definition at line 131 of file doubleArray.c.

References DoubleArrayPtr, DoubleArray::identifier, MemoryError, DoubleArray::numberOfElements, and DoubleArray::value.

void DoubleArray_destroy DoubleArrayPtr  dAPtr  ) 
 

Destroys a structure DoubleArray.

The structure DoubleArray the pointer dAPtr refers to is destroyed. All allocated memory of the structure is automatically freed.

Parameters:
dAPtr pointer on the structure DoubleArray that should be destroyed
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

Definition at line 163 of file doubleArray.c.

References AbortProgram, and DoubleArray::value.

void DoubleArray_display void *  dAPtr,
FILE *  outputStream
 

Displays a structure DoubleArray.

The structure DoubleArray the pointer dAPtr refers to is displayed on the FILE* outputStream.

Parameters:
dAPtr pointer on the structure DoubleArray that should be displayed
outputStream FILE* on the stream the output should be sent to
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

Definition at line 234 of file doubleArray.c.

References AbortProgram, DoubleArray_getNumberOfElements(), and DoubleArray_getValue().

void DoubleArray_displayIntegers const DoubleArrayPtr  dAPtr,
FILE *  outputStream
 

Displays a structure DoubleArray.

The structure DoubleArray the pointer dAPtr refers to is displayed on the FILE* outputStream. The values of each element contained in DoubleArray are treated as integers.

Parameters:
dAPtr pointer on the structure DoubleArray that should be displayed
outputStream FILE* on the stream the output should be sent to
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

Definition at line 260 of file doubleArray.c.

References AbortProgram, DoubleArray_getNumberOfElements(), and DoubleArray_getValue().

int DoubleArray_getIdentifier const DoubleArrayPtr  dAPtr  ) 
 

Returns the identifier of a structure DoubleArray.

Parameters:
dAPtr pointer on the structure DoubleArray of which the number of elements should be returned
Return values:
int unique identifier of the structure DoubleArray
Author:
Uli Fechner
Version:
05/22/2003 - Uli Fechner - initial release

Definition at line 284 of file doubleArray.c.

References DoubleArray::identifier.

Referenced by DoubleArray_copy().

int DoubleArray_getNumberOfElements const DoubleArrayPtr  dAPtr  ) 
 

Returns the number of elements of a structure DoubleArray.

The number of elements of the structure DoubleArray the pointer dAPtr refers to is returned.

Parameters:
dAPtr pointer on the structure DoubleArray of which the number of elements should be returned
Return values:
int number of elements of the structure DoubleArray
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

Definition at line 298 of file doubleArray.c.

References DoubleArray::numberOfElements.

Referenced by DoubleArray_calculateMeanAndSd(), DoubleArray_copy(), DoubleArray_display(), DoubleArray_displayIntegers(), DoubleArray_getValue(), and DoubleArray_setValue().

double DoubleArray_getValue const DoubleArrayPtr  dAPtr,
const int  index
 

The value of the element with index index of structure DoubleArray is returned.

The value of the element with index index of the structure DoubleArray dAPtr points on is returned. If the index index is greater than (numberOfElements - 1 ), the program aborts with the call of the define IndexOutOfBoundsError.

Parameters:
dAPtr pointer on the structure DoubleArray that contains the element
index index of the element the value should be returned
Return values:
double the value of the element with index index
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

Definition at line 336 of file doubleArray.c.

References DoubleArray_getNumberOfElements(), IndexOutOfBoundsError, and DoubleArray::value.

Referenced by DoubleArray_calculateMeanAndSd(), DoubleArray_copy(), DoubleArray_display(), DoubleArray_displayIntegers(), DoubleArray_lessThan(), and readDataFromStream().

int DoubleArray_lessThan void *  dAPtr1,
void *  dAPtr2
 

Evaluates if the first value of dAPtr1 is less than that of dAPtr2.

The function returns BOOLEAN_TRUE if the first value of dAPtr 1 is less than the first value of dAPtr2 and BOOLEAN_FALSE if this condition is not matched.

Parameters:
dAPtr1 pointer on the first structure DoubleArray
dAPtr2 pointer on the second structure DoubleArray
Author:
Uli Fechner
Version:
05/23/2003 - Uli Fechner - initial release

Definition at line 422 of file doubleArray.c.

References BOOLEAN_FALSE, BOOLEAN_TRUE, and DoubleArray_getValue().

void DoubleArray_setValue const DoubleArrayPtr  dAPtr,
const int  index,
const double  value
 

The element with index index of structure DoubleArray is assigned the value value.

The value value is assigned to the element with index index of the structure DoubleArray dAPtr points on. If the index index is greater than (numberOfElements - 1 ), the program aborts with the call of the define IndexOutOfBoundsError.

Parameters:
dAPtr pointer on the structure DoubleArray that contains the element
index index of the element the value value should be assigned to
value value that should be assigned to the element with index index
Author:
Uli Fechner
Version:
01/24/2003 - Uli Fechner - initial release

Definition at line 316 of file doubleArray.c.

References DoubleArray_getNumberOfElements(), IndexOutOfBoundsError, and DoubleArray::value.

Referenced by DoubleArray_calculateMeanAndSd(), DoubleArray_copy(), and getFileProperties().


Generated on Mon Nov 8 16:04:07 2004 for countSmarts by doxygen 1.3.6