Methods
Abstract: Returns a new vector containing the absolute value of the vectors elements
- (MathRealVector*)abs;
+ (void)absSrc:(MathRealVector*)src
result:(MathRealVector*)dst
overRange:(NSRange)range;
Parameters
Name | Description |
src | |
dst | |
range | |
+ (MathRealVector*)add:(MathRealVector*)op1 to:(MathRealVector*)op2;
Parameters
Name | Description |
op1 | First operand |
op2 | Second operand |
- addScalarToSelf:(float)scalar;
Adds a scalar value to all elements in the vector
- (float)angleWithVector:(MathRealVector*)v;
Parameters
Name | Description |
v | A vector |
Result: The angle between the n-dimensional vectors self and v. [0, 2pi]
- appendVector:(MathRealVector*)v;
Appends the elements of v to self.
Parameters
Name | Description |
v | The vector to append |
+ (float)applyFn2Core:(float(*)(const float*,const long))f
input:(const float*)x
length:(const long)n;
Parameters
Name | Description |
f | Function to map f(x[]) -> y |
x | Input elements array |
n | Number of elements in x array |
Result: Floating point result of function f.
- (float)applyFn2ToSelf:(float(*)(const float*,const long))f;
Parameters
Name | Description |
f | Function to map f(x[]) -> y |
Result: Floating point result of function f.
- (float)applyFn2ToSelf:(float(*)(const float*,const long))f
range:(NSRange)r;
Parameters
Name | Description |
f | Function to map f(x[]) -> y |
r | Elemenet index range over which to apply function f |
Result: Floating point result of function f.
+ (long)applyFn3Core:(long(*)(const float*,const long))f
input:(const float*)x
length:(const long)n;
Parameters
Name | Description |
f | Function to compute f(x[]) -> y |
x | Input elements array |
n | Number of elements in x |
Result: The long int result of function f applied to the array of elements x
- (long)applyFn3ToSelf:(long(*)(const float*,const long))f;
Parameters
Name | Description |
f | Function to compute f(x[]) -> y |
Result: The long int result of function f applied to the array of elements x
- (long)applyFn3ToSelf:(long(*)(const float*,const long))f
range:(NSRange)r;
Parameters
Name | Description |
f | Function to compute f(x[]) -> y |
r | Elemenet index range over which to apply function f |
Result: The long int result of function f applied to the array of elements x
+ (void)applyFnCore:(double(*)(const double))f
input:(const float*)x
output:(float*)y
length:(const long)n;
Parameters
Name | Description |
f | Function to map x[i] -> y[i] |
x | Input elements array |
y | Output elements array |
n | Number of elements in x and y arrays |
- (MathRealVector*)applyFnToSelf:(double(*)(const double))f;
The vector is mutated by the mapping - y[i] replaces x[i] in the vector.
Parameters
Name | Description |
f | Function to map x[i] -> x'[i] |
- (MathRealVector*)applyFnToSelf:(double(*)(const double))f
range:(NSRange)r;
The vector is mutated by the mapping - y[i] replaces x[i] in the vector.
Parameters
Name | Description |
f | Function to map x[i] -> x'[i] |
r | Elemenet index range over which to apply function f |
- boundElementValuesToRange:(MathRange)r;
Bounds the values of the vector's elements to the range
specified by r. Values outside the range are hard clipped to the
range boundary values.
Parameters
+ (MathRealVector*)complexAbsReal:(MathRealVector*)realV imaginary:(MathRealVector*)imagV;
Returns the complex absolute value (manitude) vector for the
supplied real and imaginary vectors' elements
Parameters
Name | Description |
realV | Vector of real values |
imagV | Vector of imaginary values |
- (MathRealVector*)convolveWithFilter:(MathRealVector*)filter;
TODO
Parameters
- copy;
Result: A fresh copy of the vector to play with.
- copyRange:(NSRange)r;
Result: A new vector containing the vector elements specified in the range.
- (MathRealVector *)crossCorrelationWith:(MathRealVector *)y;
Compute the cross-correlation of two signals x (the receiver) and y.
Parameters
- (NSMutableData*)data;
Result: Reference to the internal data object encapsulating the elements
- (MathRealVector*)deriv;
Result: A new vector containing the 1st derivative of the vectors elements.
+ (void)derivLog2Src:(MathRealVector*)src
result:(MathRealVector*)dst
overRange:(NSRange)range;
dst is set to be the first derivative of the log2(elements) of
src within the element index range.
Parameters
Name | Description |
src | |
dst | |
range | |
- derivSelf;
Vector is replaced with 1st derivative of the vectors elements.
+ (void)derivSrc:(MathRealVector*)src
result:(MathRealVector*)dst
overRange:(NSRange)range;
dst is set to be the first derivative of the elements of src
within the element index range.
Src and result must be MathRealVectors of the same length.
The subranged-src derivative is stored in the same subrange in result
This is SAFE vs src == dst
Parameters
Name | Description |
src | Input vector |
dst | Result vector |
range | |
+ (MathRealVector*)div:(MathRealVector*)op1 by:(MathRealVector*)op2;
Parameters
Name | Description |
op1 | First operand |
op2 | Second operand |
- (float)dotProductWithVector:(MathRealVector*)v;
Parameters
Name | Description |
v | A vector with the same number of elements as self. |
Result: The dot product of v with self.
- (float)elementAtIndex:(const long)index;
Returns the element at position index in the vector.
Parameters
Result: Returns the floating point element or 0.0 if the index is outside the vector length bounds.
- (float*)elements;
Result: Raw float* pointer to the elements for efficiency
- (MathComplexVector*)fft;
Result: A complex vector containing the Fourier Transform of the vector.
- (MathRealVector *)findHighest:(int)n;
Returns a MathRealVector containing the element indexes of the highest
n values in the vector. As the indexes are returned, all values in the returned
vector will be integer valued (although returned in floats). The indexes are
returned in descending order.
Parameters
Name | Description |
n | The number of highest values to find. |
Abstract: Sets all elements in the vector to one.
- initAsOnes;
- initWithData:(NSMutableData*)d;
Parameters
Name | Description |
d | An NSData object encapsulating raw float data |
Result: self
- initWithLength:(const long)l;
Parameters
- initWithVector:(MathRealVector*)v;
Parameters
Result: self
- initWithWindow:(MathWindowType)windowType length:(const long)length;
Parameters
Name | Description |
windowType | Type of window the vector will be initialized with. |
elementCount | Number of elements the vector will contain |
Result: self
- (long)length;
Result: Number of elements in the vector
- (float)max;
Returns the maximum value in the float vector.
- (long)maxPos;
Result: The index of the element with the maximum value in the vector
- (long)maxPosRange:(NSRange)r;
Parameters
Name | Description |
r | Element index range over which the function applies |
Result: index of the maximum element with the index range r.
- (float)min;
Returns the minimum value in the float vector.
- (long)minPos;
Result: The index of the element with the minimum value in the vector
- (long)minPosRange:(NSRange)r;
Result: index of the minimum element with the index range s to e.
+ (void)movingWindowMeanSrc:(MathRealVector*)srcV
result:(MathRealVector*)dstV
range:(NSRange)r
windowSize:(const long)winsize
useWindow:(int)windowID;
Parameters
Name | Description |
srcV | |
dstV | |
r | Element index range over which the function applies |
windowSize | |
windowID | |
+ (MathRealVector*)mul:(MathRealVector*)op1 by:(MathRealVector*)op2;
Parameters
Name | Description |
op1 | First operand |
op2 | Second operand |
- multSelfByScalar:(const float)f;
- (float)norm;
Euclidean norm of the vector
- normalize;
Normalize the float vector.
- printElements;
Prints all elements as text values to stdout
- readFromFile:(NSString*)filename;
Reads the elements of the vector from a column of text values from
the textfile named filename.
Parameters
- (MathRealVector *)reverse;
Reverses vector, flipping around the middle value.
Principally used for cross-correlation.
Result: Returns a new autoreleased MathRealVector
- (MathRealVector*)secondDeriv;
Vector is replaced with 2nd derivative of the vectors elements.
- secondDerivSelf;
Vector is replaced with 2nd derivative of the vectors elements.
+ (void)secondDerivSrc:(MathRealVector*)src
result:(MathRealVector*)dst
overRange:(NSRange)range;
dst is set to be the second derivative of the elements of src
within the element index range.
Parameters
Name | Description |
src | Input vector |
dst | Result vector |
range | |
- setAllElementsToValue:(const float)v;
Sets all elements in the vector to the value v.
- (MathRealVector*)setAllElementsWithFn:(double(*)(const double))f
fnInputRange:(MathRange)r;
Sets each element in the vector to a value determined by the mapping
function f. The mapping function receives equispaced
values in the range r according to the formula:
value = elementIndex * range(r) / vectorLength + min(r)
Parameters
Name | Description |
f | A double-to-double mapping function |
r | The range of input values for f |
- setElementAtIndex:(const long)index toValue:(float)value;
Assigns the element at position index in the vector to newElement.
Result: Returns self if correctly assigned, nil if the index is outside the vector length bounds.
- setLength:(const int)l;
Parameters
- (void)shiftElementsByDeltaIndex:(long)dIndex;
Parameters
- smoothRange:(NSRange)range amount:(const long)amt;
Smoothes the elements of the vector (low pass filter by local averaging)
Parameters
Name | Description |
range | Element index range over which the smoothing applies |
amount | Degree of smoothing |
+ (void)smoothSrc:(MathRealVector*)vector
result:(MathRealVector*)smoothedVector
overRange:(NSRange)range
amount:(const long)amount;
Smoothes the elements of the vector (low pass filter by local averaging)
and stores the result in smoothedVector.
Parameters
Name | Description |
vector | Input vector to be smoothed |
smoothedVector | Output vector in which to store smoothed result. |
range | Element index range over which the smoothing applies |
amount | Degree of smoothing (local averaging window size) |
- (float)stddev;
Result: Standard deviation of the vector's elements
- (float)stddevRange:(NSRange)r;
Parameters
Name | Description |
r | Element index range over which the function applies |
Result: Standard deviation of the elements over the index range s to e.
+ (MathRealVector*)subOp1:(MathRealVector*)op1 op2:(MathRealVector*)op2;
Parameters
Name | Description |
op1 | First operand |
op2 | Second operand |
- (float)sum;
Result: Sum of the vector's elements
- (float)sumRange:(NSRange)r;
Parameters
Name | Description |
r | Element index range over which the function applies |
Result: Sum of the vector's elements over range r
- (float)varRange:(NSRange)r;
Parameters
Name | Description |
r | Element index range over which the function applies |
Result: Variance of the elements over the index range s to e.
+ vectorWithData:(NSMutableData*)d;
Parameters
+ vectorWithLength:(const long)elementCount;
Parameters
Name | Description |
elementCount | Number of elements the vector will contain |
+ vectorWithVector:(MathRealVector*)aVector;
Parameters
Name | Description |
aVector | New vector is an autoreleased copy of aVector |
+ vectorWithWindow:(MathWindowType)windowType length:(const long)length;
Parameters
Name | Description |
windowType | Type of window the vector will be initialized with. |
elementCount | Number of elements the vector will contain |
- writeToFile:(NSString*)filename;
Writes the elements of the vector as a column of text values to
the textfile named filename.
Parameters
Abstract: Sets all elements in the vector to zero.
- zero;
(Last Updated 3/28/2002)