dlrNumeric/utilities.h File Reference

Header file declaring useful functions for dlrNumeric. More...

#include <cmath>
#include <cstdlib>
#include <dlrCommon/tags.h>
#include <dlrNumeric/numericTraits.h>
#include <dlrNumeric/array1D.h>
#include <dlrNumeric/array2D.h>
#include <dlrNumeric/array3D.h>
#include <dlrNumeric/index2D.h>
#include <dlrNumeric/vector2D.h>
#include <dlrNumeric/vector3D.h>
#include <sstream>
#include <numeric>

Include dependency graph for dlrNumeric/utilities.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  dlr
namespace  dlr::numeric
namespace  dlr::numeric::constants

Functions

template<class Type>
Array1D< Type > dlr::numeric::abs (const Array1D< Type > &array0)
template<class Type>
Array2D< Type > dlr::numeric::abs (const Array2D< Type > &array0)
 This function returns an array of the same size and element type as its input argument, in which each element is set to the absolute value of the corresponding element of the input array.
template<class Type>
bool dlr::numeric::allFalse (const Array1D< Type > &array0)
 This function returns true if each element of its argument is false, and returns false otherwise.
template<class Type>
bool dlr::numeric::allTrue (const Array1D< Type > &array0)
 This function returns true if each element of its argument is true, and returns false otherwise.
template<class Type>
bool dlr::numeric::anyFalse (const Array1D< Type > &array0)
 This function returns true if any element of its argument is true, and returns false otherwise.
template<class Type>
bool dlr::numeric::anyTrue (const Array1D< Type > &array0)
 This function returns true if any element of its argument is true, and returns false otherwise.
template<class Type>
size_t dlr::numeric::argmax (const Array1D< Type > &array0)
 This function returns the index of the largest element of its input array.
template<class Type, class Functor>
size_t dlr::numeric::argmax (const Array1D< Type > &array0, Functor comparator)
 This function returns the index of the largest element of its input array, where largeness is defined by the second argument.
template<class Type>
size_t dlr::numeric::argmin (const Array1D< Type > &array0)
 This function returns the index of the smallest element of its input array.
template<class Type, class Functor>
size_t dlr::numeric::argmin (const Array1D< Type > &array0, Functor comparator)
 This function returns the index of the smallest element of its input array, where smallness is defined by the second argument.
template<class Type>
Array1D< size_t > dlr::numeric::argsort (const Array1D< Type > &array0)
 This function returns an array of indices, result, so that the sequence (array0[result[0]], array0[result[1]], array0[result[2]], .
template<class Type>
Array1D< Type > dlr::numeric::axisMax (const Array2D< Type > &array0, size_t axis)
 This function is just an alias for the function axisMaximum().
template<class Type>
Array1D< Type > dlr::numeric::axisMaximum (const Array2D< Type > &array0, size_t axis)
 This function returns an Array1D in which each element has the value of the largest element in one row or column of the input Array2D.
template<class Type, class Functor>
Array1D< Type > dlr::numeric::axisMaximum (const Array2D< Type > &array0, size_t axis, Functor comparator)
 This function returns an Array1D in which each element has the value of the largest element in one row or column of the input Array2D, where largeness is defined by the third argument.
template<class Type>
Array1D< Type > dlr::numeric::axisMin (const Array2D< Type > &array0, size_t axis)
 This function is just an alias for the function axisMinimum().
template<class Type>
Array1D< Type > dlr::numeric::axisMinimum (const Array2D< Type > &array0, size_t axis)
 This function returns an Array1D in which each element has the value of the smallest element in one row or column of the input Array2D.
template<class Type, class Functor>
Array1D< Type > dlr::numeric::axisMinimum (const Array2D< Type > &array0, size_t axis, Functor comparator)
 This function returns an Array1D in which each element has the value of the smallest element in one row or column of the input Array2D, where smallness is defined by the return value of the third argument.
template<class Type>
Array1D< typename NumericTraits<
Type >::SumType > 
dlr::numeric::axisSum (const Array2D< Type > &array0, size_t axis)
 This function returns an Array1D in which each element has the sum of one row or column of the input Array2D.
template<class Type, class ResultType>
Array1D< ResultType > dlr::numeric::axisSum (const Array2D< Type > &array0, size_t axis, type_tag< ResultType > resultTag)
 This function returns an Array1D in which each element has the sum of one row or column of the input Array2D.
template<class Type, class ResultType, class Functor>
Array1D< ResultType > dlr::numeric::axisSum (const Array2D< Type > &array0, size_t axis, type_tag< ResultType > resultTag, const ResultType &initialValue, Functor adder)
 This function returns an Array1D in which each element has the sum of one row or column of the input Array2D.
template<class Type>
Array2D< Type > dlr::numeric::columnIndices (size_t rows, size_t columns, type_tag< Type > typeTag)
 columnIndices(rows, columns): Returns an Array2D in which each element contains the index of its column.
template<class Type0, class Type1>
Array1D< Type1 > dlr::numeric::compress (const Array1D< Type0 > &condition, const Array1D< Type1 > &input)
 This function selects those elements of an input Array1D which correspond to "true" values of a mask Array1D, and returns an Array1D containing only those elements.
template<class Type0, class Type1>
Array1D< Type1 > dlr::numeric::compress (const Array1D< Type0 > &condition, const Array1D< Type1 > &input, size_t numTrue)
 This function behaves in exactly the same way as compress(const Array1D&, const Array1D&), above, but it permits the user to specify the number of true elements in the condition array.
template<class Type>
size_t dlr::numeric::count (const Array1D< Type > &array0)
 This element counts the number of elements of the input array which evaluate to true, and returns that number.
Vector3D dlr::numeric::cross (const Vector3D &vector0, const Vector3D &vector1)
 This function computes the cross product of two Vector3D instances.
template<class Type>
NumericTraits< Type >::ProductType dlr::numeric::dot (const Array1D< Type > &array0, const Array1D< Type > &array1)
 This function computes the inner product of two input arrays.
template<class Type0, class Type1, class Type2>
Type2 dlr::numeric::dot (const Array1D< Type0 > &array0, const Array1D< Type1 > &array1, type_tag< Type2 > typeTag)
 This function computes the inner product of two input arrays, and allows the user to control which type is used to do the calculation.
double dlr::numeric::dot (const Vector2D &vector0, const Vector2D &vector1)
 This function computes the inner product of two Vector2D instances.
double dlr::numeric::dot (const Vector3D &vector0, const Vector3D &vector1)
 This function computes the inner product of two Vector3D instances.
template<class Type>
Array2D< Type > dlr::numeric::equivalentMatrix (const Array1D< Type > &vector0, size_t rowsInMatrix)
 This function computes from a vector, x, the matrix, X, such that the matrix product A * x is equal to the matrix product X * vec(A).
template<class Type>
void dlr::numeric::getMeanAndCovariance (const Array2D< Type > &sampleArray, Array1D< double > &mean, Array2D< double > &covariance, size_t majorAxis=0)
 This function estimates the mean and covariance of a set of vectors, which are represented by the rows (or columns) of the input 2D array.
template<class Type>
Array2D< Type > dlr::numeric::identity (size_t rows, size_t columns, type_tag< Type > typeTag)
 This function returns an Array2D instance with the specified shape in which the elements on the diagonal are set to 1, and all other elements are set to 0.
template<class Type>
Array1D< Type > dlr::numeric::ln (const Array1D< Type > &array0)
 This function returns an array in which each element is the natural logarithm of the corresponding element of its input.
template<class Type>
Array2D< Type > dlr::numeric::ln (const Array2D< Type > &array0)
 This function returns an array in which each element is the natural logarithm of the corresponding element of its input.
template<class Type>
Array2D< Type > dlr::numeric::logicalNot (const Array2D< Type > &array0)
 This function returns an Array2D instance in which the value of each element is the logical not of the corresponding element of the input array.
template<class Type>
Type dlr::numeric::magnitude (const Array1D< Type > &array0)
 This function computes the magnitude of its input argument.
double dlr::numeric::magnitude (const Vector2D &vector0)
 This function computes the magnitude of its input argument.
double dlr::numeric::magnitude (const Vector3D &vector0)
 This function computes the magnitude of its input argument.
template<class Type>
NumericTraits< Type >::ProductType dlr::numeric::magnitudeSquared (const Array1D< Type > &array0)
 This function computes the square of the magnitude of its input argument.
double dlr::numeric::magnitudeSquared (const Vector2D &vector0)
 This function computes the square of the magnitude of its input argument.
double dlr::numeric::magnitudeSquared (const Vector3D &vector0)
 This function computes the square of the magnitude of its input argument.
template<class Type>
Array1D< typename NumericTraits<
Type >::ProductType > 
dlr::numeric::matrixMultiply (const Array1D< Type > &vector0, const Array2D< Type > &matrix0)
 This function computes a vector * matrix product.
template<class Type0, class Type1, class Type2>
Array1D< Type2 > dlr::numeric::matrixMultiply (const Array1D< Type0 > &vector0, const Array2D< Type0 > &matrix0, type_tag< Type2 > typeTag)
 This function computes a vector * matrix product just like matrixMultiply(const Array1D<Type>&, const Array2D<Type>&), above.
template<class Type>
Array1D< typename NumericTraits<
Type >::ProductType > 
dlr::numeric::matrixMultiply (const Array2D< Type > &matrix0, const Array1D< Type > &vector0)
 This function computes a matrix * vector product.
template<class Type0, class Type1, class Type2>
Array1D< Type2 > dlr::numeric::matrixMultiply (const Array2D< Type0 > &matrix0, const Array1D< Type1 > &vector0, type_tag< Type2 > typeTag)
 This function computes a matrix * vector product just like matrixMultiply(const Array2D<Type>&, const Array1D<Type>&), above.
template<class Type>
Array2D< typename NumericTraits<
Type >::ProductType > 
dlr::numeric::matrixMultiply (const Array2D< Type > &matrix0, const Array2D< Type > &matrix1)
 This function computes a matrix * matrix product.
template<class Type0, class Type1, class Type2>
Array2D< Type2 > dlr::numeric::matrixMultiply (const Array2D< Type0 > &matrix0, const Array2D< Type1 > &matrix1, type_tag< Type2 > typeTag)
 This function computes a matrix * matrix product, just like matrixMultiply(const Array2D<Type>&, const Array2D<Type>&), above.
template<class Type>
Type dlr::numeric::maximum (const Array1D< Type > &array0)
 This function returns a copy of the largest element in the input Array1D instance.
template<class Type, class Functor>
Type dlr::numeric::maximum (const Array1D< Type > &array0, Functor comparator)
 This function returns a copy of the largest element in the input Array1D instance, where largeness is defined by the return value of the second argument.
template<class Iterator, class Type>
Type dlr::numeric::mean (const Iterator &beginIter, const Iterator &endIter)
 This function computes the average value, or geometric mean, of the elements of its argument.
template<class Type>
double dlr::numeric::mean (const Array1D< Type > &array0)
 This function computes the average value, or geometric mean, of the elements of its argument.
template<class Type0, class Type1>
Type1 dlr::numeric::mean (const Array1D< Type0 > &array0, type_tag< Type1 > typeTag)
 This function computes the average value, or geometric mean, of the elements of its argument, and allows the user to specify the precision with which the computation is carried out.
template<class Type>
Type dlr::numeric::minimum (const Array1D< Type > &array0)
 This function returns a copy of the smallest element in the input Array1D instance.
template<class Type, class Functor>
Type dlr::numeric::minimum (const Array1D< Type > &array0, Functor comparator)
 This function returns a copy of the smallest element in the input Array1D instance, where largeness is defined by the return value of the second argument.
template<class FUNCTOR>
double dlr::numeric::newtonRaphson (double startPoint, FUNCTOR objectiveFunction, double epsilon, size_t maxIterations)
 This function uses the iterative method of Newton and Raphson to search for a zero crossing of the supplied functor.
template<class Type>
double dlr::numeric::normalizedCorrelation (const Array1D< Type > &x, const Array1D< Type > &y)
 This function computes the normalized correlation of two Array1D arguments.
template<class Type, class Type2>
Type2 dlr::numeric::normalizedCorrelation (const Array1D< Type > &x, const Array1D< Type > &y, type_tag< Type2 > typeTag)
 This function is equivalent to normalizedCorrelation(const Array1D&, const Array1D&), except that the computation is carried out using the type specified by the third argument.
template<class Type>
Array1D< Type > dlr::numeric::ones (int size, type_tag< Type > typeTag)
 This function returns an Array1D of the specified size and type in which the value of every element is initialized to 1.
template<class Type>
Array2D< Type > dlr::numeric::ones (int rows, int columns, type_tag< Type > typeTag)
 This function returns an Array2D of the specified size and type in which the value of every element is initialized to one.
template<class Type>
Array2D< typename NumericTraits<
Type >::ProductType > 
dlr::numeric::outerProduct (const Array1D< Type > &array0, const Array1D< Type > &array1)
 This function computes the outer product of two input Array1D instances.
template<class Type0, class Type1, class Type2>
Array2D< Type2 > dlr::numeric::outerProduct (const Array1D< Type0 > &array0, const Array1D< Type1 > &array1, type_tag< Type2 > typeTag)
 This function computes the outer product of two input Array1D instances and allows the user to control which type is used to do the calculation.
template<class Type>
Array1D< Type > dlr::numeric::range (Type start, Type stop, Type stride=1)
 This function returns an Array1D in which the first element has value equal to argument "start," and each subsequent element has value equal to the previous element plus argument "stride." The length of the array is equal to largest integer less than the quantity ((stop - start) / stride).
template<class Type>
Array1D< Type > dlr::numeric::ravel (Array2D< Type > &inputArray)
 This function takes an Array2D argument and returns an Array1D instance which references the same data.
template<class Type>
const Array1D< Type > dlr::numeric::ravel (const Array2D< Type > &inputArray)
 This function takes a const Array2D argument and returns a const Array1D instance which references the same data.
template<class Type>
Type dlr::numeric::rms (const Array1D< Type > &array0)
 This function computes the RMS (Root Mean Square) value of the elements of its argument.
template<class Type0, class Type1>
Type1 dlr::numeric::rms (const Array1D< Type0 > &array0, type_tag< Type1 > typeTag)
 This function computes the RMS (Root Mean Square) value of the elements of its argument, and allows the user to specify the precision with which the computation is carried out.
template<class Type>
Array2D< Type > dlr::numeric::rowIndices (size_t rows, size_t columns, type_tag< Type > typeTag)
 rowIndices(rows, columns): Returns an Array2D in which each element contains the index of its row.
template<class Type0, class Type1>
bool dlr::numeric::shapeMatch (const Array1D< Type0 > &array0, const Array1D< Type1 > &array1)
 This function returns true if the two arrays have the same shape, false otherwise.
template<class Type0, class Type1>
bool dlr::numeric::shapeMatch (const Array2D< Type0 > &array0, const Array2D< Type1 > &array1)
 This function returns true if the two arrays have the same shape, false otherwise.
template<class Type0, class Type1>
bool dlr::numeric::shapeMatch (const Array3D< Type0 > &array0, const Array3D< Type1 > &array1)
 This function returns true if the two arrays have the same shape, false otherwise.
template<class Type>
Array2D< Type > dlr::numeric::skewSymmetric (const Array1D< Type > &vector0)
 skewSymmetric(x): Returns a skew symmetric matrix X such that matrixMultiply(X, y) = cross(x, y)
template<class Type>
void dlr::numeric::solveQuadratic (Type c0, Type c1, Type c2, Type &root0, Type &root1, bool &valid, bool checkValidity=true)
 This function computes the real roots of the quadratic polynomial c0*x^2 + c1*x + c0 = 0.
template<class Type>
double dlr::numeric::standardDeviation (const Array1D< Type > &array0)
 This function computes the standard deviation of a group of scalar samples.
template<class Type0, class Type1>
Type1 dlr::numeric::standardDeviation (const Array1D< Type0 > &array0, type_tag< Type1 > typeTag)
 This function computes the standard deviation of the elements of its argument, and allows the user to specify the precision with which the computation is carried out.
template<class Type>
NumericTraits< Type >::SumType dlr::numeric::sum (const Array1D< Type > &array0)
 This function computes the sum of the elements of its argument.
template<class Type, class Type2>
Type2 dlr::numeric::sum (const Array1D< Type > &array0, type_tag< Type2 > typeTag)
 This function computes the sum of the elements of its argument.
template<class Type>
NumericTraits< Type >::SumType dlr::numeric::sum (const Array2D< Type > &array0, const Index2D &upperLeftCorner, const Index2D &lowerRightCorner)
 This function computes the sum of those elements of its argument which lie within a rectangular region of interest.
template<class Type, class Type2>
Type2 dlr::numeric::sum (const Array2D< Type > &array0, const Index2D &upperLeftCorner, const Index2D &lowerRightCorner, type_tag< Type2 > typeTag)
 This function computes the sum of those elements of its argument which lie within a rectangular region of interest.
template<class Type>
double dlr::numeric::variance (const Array1D< Type > &array0)
 This function computes the variance of a group of scalar samples.
template<class Type0, class Type1>
Type1 dlr::numeric::variance (const Array1D< Type0 > &array0, type_tag< Type1 > typeTag)
 This function computes the variance, of the elements of its argument, and allows the user to specify the precision with which the computation is carried out.
template<class Type>
Array1D< Type > dlr::numeric::zeros (size_t size, type_tag< Type > typeTag)
 This function returns an Array1D of the specified size and type in which the value of every element is zero.
template<class Type>
Array2D< Type > dlr::numeric::zeros (size_t rows, size_t columns, type_tag< Type > typeTag)
 This function returns an Array2D of the specified size and type in which the value of every element is zero.
template<class Type>
Array3D< Type > dlr::numeric::zeros (size_t shape0, size_t shape1, size_t shape2, type_tag< Type > typeTag)
 This function returns an Array3D of the specified size and type in which the value of every element is zero.

Variables

const double dlr::numeric::constants::pi = 3.141592653589793238


Detailed Description

Header file declaring useful functions for dlrNumeric.

Copyright (C) 2001-2007 David LaRose, dlr@cs.cmu.edu See accompanying file, LICENSE.TXT, for details.

Revision
938
Date
2007-06-09 13:06:25 -0400 (Sat, 09 Jun 2007)

Definition in file dlrNumeric/utilities.h.


Generated on Mon Jul 9 20:34:18 2007 for dlrLibs Utility Libraries by  doxygen 1.5.2