Methods



abs

Abstract: Returns a new vector containing the absolute value of the vectors elements
- (MathRealVector*)abs; 


absSrc:result:overRange:

+ (void)absSrc:(MathRealVector*)src
 result:(MathRealVector*)dst
 overRange:(NSRange)range; 

Parameters

NameDescription
src
dst
range

add:to:

+ (MathRealVector*)add:(MathRealVector*)op1 to:(MathRealVector*)op2; 

Parameters

NameDescription
op1First operand
op2Second operand

addScalar:

-  addScalarToSelf:(float)scalar; 

Adds a scalar value to all elements in the vector


angleWithVector:

- (float)angleWithVector:(MathRealVector*)v; 

Parameters

NameDescription
vA vector
Result: The angle between the n-dimensional vectors self and v. [0, 2pi]

appendVector:

-  appendVector:(MathRealVector*)v; 

Appends the elements of v to self.

Parameters

NameDescription
vThe vector to append

applyFn2Core:input:length:

+ (float)applyFn2Core:(float(*)(const float*,const long))f
 input:(const float*)x
 length:(const long)n; 

Parameters

NameDescription
fFunction to map f(x[]) -> y
xInput elements array
nNumber of elements in x array
Result: Floating point result of function f.

applyFn2ToSelf:

- (float)applyFn2ToSelf:(float(*)(const float*,const long))f; 

Parameters

NameDescription
fFunction to map f(x[]) -> y
Result: Floating point result of function f.

applyFn2ToSelf:range:

- (float)applyFn2ToSelf:(float(*)(const float*,const long))f
 range:(NSRange)r; 

Parameters

NameDescription
fFunction to map f(x[]) -> y
rElemenet index range over which to apply function f
Result: Floating point result of function f.

applyFn3Core:input:length:

+ (long)applyFn3Core:(long(*)(const float*,const long))f
 input:(const float*)x
 length:(const long)n; 

Parameters

NameDescription
fFunction to compute f(x[]) -> y
xInput elements array
nNumber of elements in x
Result: The long int result of function f applied to the array of elements x

applyFn3ToSelf:

- (long)applyFn3ToSelf:(long(*)(const float*,const long))f; 

Parameters

NameDescription
fFunction to compute f(x[]) -> y
Result: The long int result of function f applied to the array of elements x

applyFn3ToSelf:range:

- (long)applyFn3ToSelf:(long(*)(const float*,const long))f
 range:(NSRange)r; 

Parameters

NameDescription
fFunction to compute f(x[]) -> y
rElemenet index range over which to apply function f
Result: The long int result of function f applied to the array of elements x

applyFnCore:input:output:length:

+ (void)applyFnCore:(double(*)(const double))f
 input:(const float*)x
 output:(float*)y
 length:(const long)n; 

Parameters

NameDescription
fFunction to map x[i] -> y[i]
xInput elements array
yOutput elements array
nNumber of elements in x and y arrays

applyFnToSelf:

- (MathRealVector*)applyFnToSelf:(double(*)(const double))f; 

The vector is mutated by the mapping - y[i] replaces x[i] in the vector.

Parameters

NameDescription
fFunction to map x[i] -> x'[i]

applyFnToSelf:range:

- (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

NameDescription
fFunction to map x[i] -> x'[i]
rElemenet index range over which to apply function f

boundElementValuesToRange:

-  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

NameDescription
r

complexAbsReal:imaginary:

+ (MathRealVector*)complexAbsReal:(MathRealVector*)realV imaginary:(MathRealVector*)imagV; 

Returns the complex absolute value (manitude) vector for the supplied real and imaginary vectors' elements

Parameters

NameDescription
realVVector of real values
imagVVector of imaginary values

convolveWithFilter:

- (MathRealVector*)convolveWithFilter:(MathRealVector*)filter; 

TODO

Parameters

NameDescription
filter

copy

-  copy; 

Result: A fresh copy of the vector to play with.

copyRange:

-  copyRange:(NSRange)r; 

Result: A new vector containing the vector elements specified in the range.

crossCorrelationWith:

- (MathRealVector *)crossCorrelationWith:(MathRealVector *)y; 

Compute the cross-correlation of two signals x (the receiver) and y.

Parameters

NameDescription
y

data

- (NSMutableData*)data; 

Result: Reference to the internal data object encapsulating the elements

deriv

- (MathRealVector*)deriv; 

Result: A new vector containing the 1st derivative of the vectors elements.

derivLog2Src:result:overRange:

+ (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

NameDescription
src
dst
range

derivSelf

-  derivSelf; 

Vector is replaced with 1st derivative of the vectors elements.


derivSrc:result:overRange:

+ (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

NameDescription
srcInput vector
dstResult vector
range

div:by:

+ (MathRealVector*)div:(MathRealVector*)op1 by:(MathRealVector*)op2; 

Parameters

NameDescription
op1First operand
op2Second operand

dotProductWithVector:

- (float)dotProductWithVector:(MathRealVector*)v; 

Parameters

NameDescription
vA vector with the same number of elements as self.
Result: The dot product of v with self.

elementAtIndex:

- (float)elementAtIndex:(const long)index; 

Returns the element at position index in the vector.

Parameters

NameDescription
index
Result: Returns the floating point element or 0.0 if the index is outside the vector length bounds.

elements

- (float*)elements; 

Result: Raw float* pointer to the elements for efficiency

fft

- (MathComplexVector*)fft; 

Result: A complex vector containing the Fourier Transform of the vector.

findHighest:

- (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

NameDescription
nThe number of highest values to find.

initAsOnes

Abstract: Sets all elements in the vector to one.
-  initAsOnes; 


initWithData:

-  initWithData:(NSMutableData*)d; 

Parameters

NameDescription
dAn NSData object encapsulating raw float data
Result: self

initWithLength:

-  initWithLength:(const long)l; 

Parameters

NameDescription
l

initWithVector:

-  initWithVector:(MathRealVector*)v; 

Parameters

NameDescription
v
Result: self

initWithWindow:length:

-  initWithWindow:(MathWindowType)windowType length:(const long)length; 

Parameters

NameDescription
windowTypeType of window the vector will be initialized with.
elementCountNumber of elements the vector will contain
Result: self

length

- (long)length; 

Result: Number of elements in the vector

max

- (float)max; 

Returns the maximum value in the float vector.


maxPos

- (long)maxPos; 

Result: The index of the element with the maximum value in the vector

maxPosRange:

- (long)maxPosRange:(NSRange)r; 

Parameters

NameDescription
rElement index range over which the function applies
Result: index of the maximum element with the index range r.

min

- (float)min; 

Returns the minimum value in the float vector.


minPos

- (long)minPos; 

Result: The index of the element with the minimum value in the vector

minPosRange:

- (long)minPosRange:(NSRange)r; 

Result: index of the minimum element with the index range s to e.

movingWindowMeanSrc:result:range:winSize:useWindow:

+ (void)movingWindowMeanSrc:(MathRealVector*)srcV
 result:(MathRealVector*)dstV
 range:(NSRange)r
 windowSize:(const long)winsize
 useWindow:(int)windowID; 

Parameters

NameDescription
srcV
dstV
rElement index range over which the function applies
windowSize
windowID

mul:by:

+ (MathRealVector*)mul:(MathRealVector*)op1 by:(MathRealVector*)op2; 

Parameters

NameDescription
op1First operand
op2Second operand

multSelfByScalar:

-  multSelfByScalar:(const float)f; 


norm

- (float)norm; 

Euclidean norm of the vector


normalize

-  normalize; 

Normalize the float vector.


printElements

-  printElements; 

Prints all elements as text values to stdout


readFromFile:

-  readFromFile:(NSString*)filename; 

Reads the elements of the vector from a column of text values from the textfile named filename.

Parameters

NameDescription
filename

reverse

- (MathRealVector *)reverse; 

Reverses vector, flipping around the middle value. Principally used for cross-correlation.

Result: Returns a new autoreleased MathRealVector

secondDeriv

- (MathRealVector*)secondDeriv; 

Vector is replaced with 2nd derivative of the vectors elements.


secondDerivSelf

-  secondDerivSelf; 

Vector is replaced with 2nd derivative of the vectors elements.


secondDerivSrc:result:overRange:

+ (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

NameDescription
srcInput vector
dstResult vector
range

setAllElementsToValue:

-  setAllElementsToValue:(const float)v; 

Sets all elements in the vector to the value v.


setAllElementsWithFn:fnInputRange:

- (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

NameDescription
fA double-to-double mapping function
rThe range of input values for f

setElement:atIndex:

-  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:

-  setLength:(const int)l; 

Parameters

NameDescription
l

shiftElementsByDeltaIndex:

- (void)shiftElementsByDeltaIndex:(long)dIndex; 

Parameters

NameDescription
dIndex

smoothRange:amount:

-  smoothRange:(NSRange)range amount:(const long)amt; 

Smoothes the elements of the vector (low pass filter by local averaging)

Parameters

NameDescription
rangeElement index range over which the smoothing applies
amountDegree of smoothing

smoothSrc:result:overRange:amount:

+ (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

NameDescription
vectorInput vector to be smoothed
smoothedVectorOutput vector in which to store smoothed result.
rangeElement index range over which the smoothing applies
amountDegree of smoothing (local averaging window size)

stddev

- (float)stddev; 

Result: Standard deviation of the vector's elements

stddevRange:

- (float)stddevRange:(NSRange)r; 

Parameters

NameDescription
rElement index range over which the function applies
Result: Standard deviation of the elements over the index range s to e.

subOp1:op2:

+ (MathRealVector*)subOp1:(MathRealVector*)op1 op2:(MathRealVector*)op2; 

Parameters

NameDescription
op1First operand
op2Second operand

sum

- (float)sum; 

Result: Sum of the vector's elements

sumRange:

- (float)sumRange:(NSRange)r; 

Parameters

NameDescription
rElement index range over which the function applies
Result: Sum of the vector's elements over range r

varRange:

- (float)varRange:(NSRange)r; 

Parameters

NameDescription
rElement index range over which the function applies
Result: Variance of the elements over the index range s to e.

vectorWithData:

+  vectorWithData:(NSMutableData*)d; 

Parameters

NameDescription
d

vectorWithLength:

+  vectorWithLength:(const long)elementCount; 

Parameters

NameDescription
elementCountNumber of elements the vector will contain

vectorWithVector:

+  vectorWithVector:(MathRealVector*)aVector; 

Parameters

NameDescription
aVectorNew vector is an autoreleased copy of aVector

vectorWithWindow:length:

+  vectorWithWindow:(MathWindowType)windowType length:(const long)length; 

Parameters

NameDescription
windowTypeType of window the vector will be initialized with.
elementCountNumber of elements the vector will contain

writeToFile:

-  writeToFile:(NSString*)filename; 

Writes the elements of the vector as a column of text values to the textfile named filename.

Parameters

NameDescription
filename

zero

Abstract: Sets all elements in the vector to zero.
-  zero; 


(Last Updated 3/28/2002)