Main Page   Modules   Alphabetical List   Compound List   Compound Members  

Vector


Functions

cpl_vector * cpl_vector_new (const int n)
 Create a new cpl_vector. More...

void cpl_vector_delete (cpl_vector *v)
 Delete a cpl_vector. More...

void cpl_vector_dump (const cpl_vector *v, FILE *f)
 Dump a cpl_vector in a file or stdout. More...

cpl_vector * cpl_vector_read (const char *filename)
 Read a list of points from an ASCII file and create a cpl_vector. More...

cpl_vector * cpl_vector_duplicate (const cpl_vector *v)
 This function duplicates an existing vector and allocates memory. More...

cpl_error_code cpl_vector_copy (cpl_vector *destination, const cpl_vector *source)
 This function copies contents of a vector into another vector. More...

int cpl_vector_get_size (const cpl_vector *in)
 Get the size of the vector. More...

double * cpl_vector_get_data (const cpl_vector *in)
 Get a pointer to the data part of the vector. More...

cpl_error_code cpl_vector_add (cpl_vector *v1, const cpl_vector *v2)
 Add a cpl_vector to another. More...

cpl_error_code cpl_vector_subtract (cpl_vector *v1, const cpl_vector *v2)
 Subtract a cpl_vector from another. More...

cpl_error_code cpl_vector_multiply (cpl_vector *v1, const cpl_vector *v2)
 Multiply two vectors component-wise. More...

cpl_error_code cpl_vector_divide (cpl_vector *v1, const cpl_vector *v2)
 Divide two vectors component-wise. More...

cpl_error_code cpl_vector_sort (cpl_vector *v, const int c)
 Sort a cpl_vector by increasing/decreasing data. More...

cpl_error_code cpl_vector_const_op (cpl_vector *v, const double value, const int operation)
 Constant arithmetic on a vector. More...

cpl_error_code cpl_vector_fill (cpl_vector *v, const double val)
 Fill a cpl_vector. More...

cpl_error_code cpl_vector_sqrt (cpl_vector *v)
 Compute the sqrt of a cpl_vector. More...

cpl_error_code cpl_vector_threshold (cpl_vector *v, const int side, const double value)
 Set to a value the elements above or under this value. More...

int cpl_vector_compare (const cpl_vector *v1, const cpl_vector *v2, const double tolerance)
 Compare two vectors. More...

int cpl_vector_find_index (const cpl_vector *v, const double key, int *found_ptr)
 Find the abscissa index just below a given value in a vector. More...

double cpl_vector_min (const cpl_vector *v)
 Get the minimum of the cpl_vector. More...

double cpl_vector_max (const cpl_vector *v)
 Get the maximum of the cpl_vector. More...

double cpl_vector_mean (const cpl_vector *v)
 Compute the mean value of vector elements. More...

double cpl_vector_mean_reject (const cpl_vector *v, const int low, const int high)
 Sorts the input vector, takes out highest and lowest values, and returns the average of the remaining data. More...

cpl_vector * cpl_vector_filter_lowpass (const cpl_vector *v, const int filter_type, const int hw)
 Apply a low-pass filter to a cpl_vector. More...

cpl_vector * cpl_vector_filter_median (const cpl_vector *v, const int hw)
 Apply a 1d median filter of given half-width to a cpl_vector. More...


Detailed Description

This module provides functions to handle cpl_vector.

A cpl_vector is an object containing a list of values (as doubles) and the number of values. The functionalities provided here are simple ones like sorting, statistics, or simple operations. The cpl_1dfunction object is composed of two of these vectors.

Synopsis:
   #include "cpl_vector.h"

Function Documentation

cpl_error_code cpl_vector_add cpl_vector *    v1,
const cpl_vector *    v2
 

Add a cpl_vector to another.

Parameters:
v1  First cpl_vector (modified)
v2  Second cpl_vector
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
The second vector is added to the first one. The input first vector is modified. The input vectors must be the same size

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

int cpl_vector_compare const cpl_vector *    v1,
const cpl_vector *    v2,
const double    tolerance
 

Compare two vectors.

Parameters:
v1  First cpl_vector
v2  Second cpl_vector
tolerance  Maximal (non-negative) elementwise difference
Returns:
0 if v1=v2, 1 if v1!=v2, -1 in error case
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_error_code cpl_vector_const_op cpl_vector *    v,
const double    value,
const int    operation
 

Constant arithmetic on a vector.

Parameters:
v  input vector
value  Constant operand.
operation  Operation to perform.
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
Possible operations are:
  • '+' Addition
  • '-' Subtraction
  • '*' Multiplication
  • '/' Division
  • 'l' Logarithm
  • '^' Power
  • 'e' Exponentiation
When logarithm or exponentiation are computed, the passed constant represents the base of the logarithm or of the exponentiation operation.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_DIVISION_BY_ZERO
  • CPL_ERROR_UNSUPPORTED_MODE

cpl_error_code cpl_vector_copy cpl_vector *    destination,
const cpl_vector *    source
 

This function copies contents of a vector into another vector.

Parameters:
destination  destination cpl_vector
source  source cpl_vector
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

void cpl_vector_delete cpl_vector *    v
 

Delete a cpl_vector.

Parameters:
v  cpl_vector to delete
Returns:
void

cpl_error_code cpl_vector_divide cpl_vector *    v1,
const cpl_vector *    v2
 

Divide two vectors component-wise.

Parameters:
v1  First cpl_vector
v2  Second cpl_vector
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
The first vector is divided by the second one. The input first vector is modified. The input vectors must be the same size

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

void cpl_vector_dump const cpl_vector *    v,
FILE *    f
 

Dump a cpl_vector in a file or stdout.

Parameters:
v  cpl_vector to dump
f  File where the cpl_vector is written
Returns:
void
Dump a cpl_vector in a file. The second parameter accepts stdout or stderr.

cpl_vector* cpl_vector_duplicate const cpl_vector *    v
 

This function duplicates an existing vector and allocates memory.

Parameters:
v  the input cpl_vector
Returns:
a newly allocated cpl_vector or NULL in error case
The returned object must be deallocated using cpl_vector_delete()

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_error_code cpl_vector_fill cpl_vector *    v,
const double    val
 

Fill a cpl_vector.

Parameters:
v  cpl_vector
val  Value used to fill the cpl_vector
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
Input vector is modified

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

cpl_vector* cpl_vector_filter_lowpass const cpl_vector *    v,
const int    filter_type,
const int    hw
 

Apply a low-pass filter to a cpl_vector.

Parameters:
v  cpl_vector
filter_type  Type of filter to use
hw  Filter half-width
Returns:
Pointer to newly allocated cpl_vector or NULL in error case
This type of low-pass filtering consists in a convolution with a given kernel. The chosen filter type determines the kind of kernel to apply for convolution. Possible kernels and associated symbols can be found in cpl_vector.h Smoothing the cpl_vector is done by applying this type of low-pass filter several times. The returned smooth cpl_vector must be deallocated using cpl_vector_delete(). The returned signal has exactly as many samples as the input signal.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_vector* cpl_vector_filter_median const cpl_vector *    v,
const int    hw
 

Apply a 1d median filter of given half-width to a cpl_vector.

Parameters:
v  cpl_vector
hw  Filter half-width
Returns:
Pointer to newly allocated cpl_vector or NULL in error case
This function applies a median smoothing to a cpl_vector and returns a newly allocated cpl_vector containing a median-smoothed version of the input. The returned cpl_vector has exactly as many samples as the input one. It must be deallocated using cpl_vector_delete(). For half-widths of 1,2,3,4, the filtering is optimised for speed.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

int cpl_vector_find_index const cpl_vector *    v,
const double    key,
int *    found_ptr
 

Find the abscissa index just below a given value in a vector.

Parameters:
v  input cpl_vector
key  value to find
found_ptr  Output flag, 1 if value was found, else 0.
Returns:
The largest index for which v[index] < key or -1 on error
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

double* cpl_vector_get_data const cpl_vector *    in
 

Get a pointer to the data part of the vector.

Parameters:
in  the input vector
Returns:
Pointer to the data or NULL in error case
The returned pointer refers to already allocated data.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

int cpl_vector_get_size const cpl_vector *    in
 

Get the size of the vector.

Parameters:
in  the input vector
Returns:
The size or -1 in error case
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT

double cpl_vector_max const cpl_vector *    v
 

Get the maximum of the cpl_vector.

Parameters:
v  const cpl_vector
Returns:
the maximum value of the vector
See also:
cpl_vector_min()

double cpl_vector_mean const cpl_vector *    v
 

Compute the mean value of vector elements.

Parameters:
v  Input const cpl_vector
Returns:
Mean value of vector elements.
See also:
cpl_vector_min()

double cpl_vector_mean_reject const cpl_vector *    v,
const int    low,
const int    high
 

Sorts the input vector, takes out highest and lowest values, and returns the average of the remaining data.

Parameters:
v  Input const cpl_vector
low  Non-negative number of lowest values to reject.
high  Non-negative number of highest values to reject.
Returns:
The filtered average of the input signal.
The input signal is first copied. This copy is then sorted, and the highest and lowest values are taken out of the list. Remaining data are averaged and the result is returned.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

double cpl_vector_min const cpl_vector *    v
 

Get the minimum of the cpl_vector.

Parameters:
v  const cpl_vector
Returns:
the minimum value of the vector
In case of error, the _cpl_error_code_ code is set, and the returned double is undefined.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_error_code cpl_vector_multiply cpl_vector *    v1,
const cpl_vector *    v2
 

Multiply two vectors component-wise.

Parameters:
v1  First cpl_vector
v2  Second cpl_vector
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
See also:
cpl_vector_add()

cpl_vector* cpl_vector_new const int    n
 

Create a new cpl_vector.

Parameters:
n  Number of element of the cpl_vector
Returns:
1 newly allocated cpl_vector or NULL in error case
The returned object must be deallocated using cpl_vector_delete().

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_ILLEGAL_INPUT

cpl_vector* cpl_vector_read const char *    filename
 

Read a list of points from an ASCII file and create a cpl_vector.

Parameters:
filename  Name of the input ASCII file
Returns:
1 newly allocated cpl_vector or NULL in error case
Parse an input ASCII file values and fill a cpl_vector with it Lines beginning with a hash are ignored, blank lines also. The returned object must be deallocated using cpl_vector_delete()

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_FILE_IO

cpl_error_code cpl_vector_sort cpl_vector *    v,
const int    c
 

Sort a cpl_vector by increasing/decreasing data.

Parameters:
v  cpl_vector to sort
c  Sorting criterion to use
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
The input cpl_vector is modified to sort out all values following the sorting criterion. Possible sorting criteria are:
  • +1 to sort by increasing data
  • -1 to sort by decreasing data
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_error_code cpl_vector_sqrt cpl_vector *    v
 

Compute the sqrt of a cpl_vector.

Parameters:
v  cpl_vector
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
The sqrt of the data is computed. The input cpl_vector is modified

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_error_code cpl_vector_subtract cpl_vector *    v1,
const cpl_vector *    v2
 

Subtract a cpl_vector from another.

Parameters:
v1  First cpl_vector (modified)
v2  Second cpl_vector
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
See also:
cpl_vector_add()

cpl_error_code cpl_vector_threshold cpl_vector *    v,
const int    side,
const double    value
 

Set to a value the elements above or under this value.

Parameters:
v  cpl_vector
side  0: replace values under the value, 1: above the value
value  threshold
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT


Generated on Mon May 24 14:58:05 2004 for Common Pipeline Library Reference Manual by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002