Code Packages  1
Add-on code processing modules
Public Member Functions | Static Public Member Functions | Properties | List of all members
dsp.NArray< T > Class Template Reference

Numeric array class provides a generic array data type and a usefull set of numeric array calculations. More...

Inheritance diagram for dsp.NArray< T >:

Public Member Functions

 NArray (T[] value)
 Initialize a new instance of NArray class using another array More...
 
 NArray (int size)
 Initialize a new instance of NArray class More...
 
void Add (T arg)
 Used internally for initialization upon declaration. More...
 
void Clear ()
 Clears all items of the NArray More...
 
NArray< T > Copy ()
 
override bool Equals (object obj)
 
IEnumerator GetEnumerator ()
 Returns an enumerator that iterates through a collection. More...
 
override int GetHashCode ()
 
override string ToString ()
 Converts the NArray to its string representation More...
 

Static Public Member Functions

static double [] Abs (double[] A)
 Calculate the absolute value on each sample of a real array More...
 
static double [] Acos (double[] A)
 Calculate the arccosine on each sample of a real array More...
 
static Complex [] Acos (Complex[] A)
 Calculate the arcsine on each sample of a complex array More...
 
static T [] Add< T > (params T[][] args)
 Perform addition on multiple arrays More...
 
static T [] Add< T > (T[] A, T value)
 Add all samples of an array with a specified value More...
 
static bool [] AND (params bool[][] args)
 AND Gate More...
 
static double [] Asin (double[] A)
 Calculate the arcsine on each sample of a real array More...
 
static Complex [] Asin (Complex[] A)
 Calculate the arccosine on each sample of a complex array More...
 
static double [] Atan (double[] A)
 Calculate the arctangent on each sample of a real array More...
 
static Complex [] Atan (Complex[] A)
 Calculate the arctangent on each sample of a complex array More...
 
static double [] Atan2 (double[] A, double[] B)
 Calculate the arctangent using the quotient of two real arrays More...
 
static Complex [] Conjugate (Complex[] A)
 Returns the complex conjugate of a complex array More...
 
static double [] Cos (double[] A)
 Calculate the cosine on each sample of a real array More...
 
static Complex [] Cos (Complex[] A)
 Calculate the cosine on each sample of a complex array More...
 
static double [] Cosh (double[] A)
 Calculate the hyperbolic cosine on each sample of a real array More...
 
static Complex [] Cosh (Complex[] A)
 Calculate the hyperbolic cosine on each sample of a complex array. More...
 
static double [] DegToRad (double[] A)
 Convert a set of values representing degrees into radians More...
 
static T [] Div< T > (T[] A, T[] B)
 Perform division using two arrays More...
 
static T [] Div< T > (T[] A, T value)
 Divide all samples of an array with a the specified value More...
 
static double [] Img (Complex[] A)
 Get the imaginary part of a complex array More...
 
static bool IsInfinity (double[] A)
 Check if a real array contains a sample that has infinite value More...
 
static bool IsInfinity (Complex[] A)
 Check if a complex array contains a sample that has infinite value More...
 
static bool IsNaN (double[] A)
 Check if a real array contains a sample that is not a number More...
 
static bool IsNaN (Complex[] A)
 Check if a complex array contains a sample that is not a number More...
 
static bool IsSizeEqual< T > (params T[][] args)
 Check if the specified arrays have equal size More...
 
static bool IsSizeEven< T > (T[] A)
 Check if an array has an even number of samples More...
 
static T [] LeftShift< T > (T[] A, int samples, T value)
 Left shift an array by number of samples with value feed More...
 
static double [] Ln (double[] A)
 Calculate the natural logarithm on each sample of a real array More...
 
static Complex [] Ln (Complex[] A)
 Calculate the natural logarithm on each sample of a complex array More...
 
static double [] Log (double[] A, double _base)
 Calculate the logarithm on each sample of a real array using the specified base More...
 
static Complex [] Log (Complex[] A, double _base)
 Calculate the logarithm on each sample of a complex array using a real base More...
 
static Complex [] Log (Complex[] A, Complex _base)
 Calculate the logarithm on each sample of a complex array using a complex base More...
 
static double [] Log10 (double[] A)
 Calculate the logarithm of base10 on each sample of a real array More...
 
static Complex [] Log10 (Complex[] A)
 Calculate the logarithm of base10 on each sample of a complex array More...
 
static double [] Magnitude (Complex[] A)
 Returns the magnitude (abs) on each sample of a complex array More...
 
static int MaxSize< T > (params T[][] args)
 Returns the maximum size found on multiple arrays More...
 
static T [] Merge< T > (params T[][] args)
 Concatenate multiple arrays More...
 
static int MinSize< T > (params T[][] args)
 Returns the minimum size found on multiple arrays More...
 
static T [] Mul< T > (params T[][] args)
 Perform multiplication on multiple arrays More...
 
static T [] Mul< T > (T[] A, T value)
 Multiply all samples of an array with the specified value More...
 
static T [] Negate< T > (T[] A)
 Returns the additive reverse (opposite) of an array More...
 
static bool [] NOT (bool[] A)
 NOT Gate More...
 
static implicit operator NArray< T > (T[] value)
 Converts (implicitly) an array to NArray More...
 
static implicit operator T[] (NArray< T > value)
 Converts (implicitly) a NArray to array More...
 
static bool operator!= (NArray< T > A, NArray< T > B)
 Inequality check of two NArray More...
 
static NArray< T > operator* (NArray< T > A, NArray< T > B)
 Performs NArray multiplication More...
 
static NArray< T > operator* (NArray< T > A, T value)
 Performs multiplication using a scalar More...
 
static NArray< T > operator+ (NArray< T > A, NArray< T > B)
 Performs NArray addition More...
 
static NArray< T > operator+ (NArray< T > A, T value)
 Performs addition using a scalar More...
 
static NArray< T > operator- (NArray< T > A, NArray< T > B)
 Performs NArray subtraction More...
 
static NArray< T > operator- (NArray< T > A, T value)
 Performs subtraction using a scalar More...
 
static NArray< T > operator- (NArray< T > A)
 Negates (opposite) all items in NArray More...
 
static NArray< T > operator/ (NArray< T > A, NArray< T > B)
 Performs NArray division More...
 
static NArray< T > operator/ (NArray< T > A, T value)
 Performs division using a scalar More...
 
static bool operator== (NArray< T > A, NArray< T > B)
 Equality check of two NArray More...
 
static bool [] OR (params bool[][] args)
 OR Gate More...
 
static T [] Padd< T > (T[] A, int samples, T value)
 Padd an array by number of samples using value fill More...
 
static T [] PaddRadix2< T > (T[] A, T value)
 Padd an array till size reach a power of two using value fill More...
 
static double [] Phase (Complex[] A)
 Returns the phase in radians on each sample of a complex array More...
 
static Complex [] PolarToRec (double[] A_mag, double[] A_phase)
 Polar-to-Rectangular array conversion More...
 
static double [] Pow (double[] A, double exponent)
 Calculate power on each sample of a real array using the specified exponent More...
 
static double [] Pow (double[] A, int exponent)
 Calculate power on each sample of a real array using the specified exponent More...
 
static Complex [] Pow (Complex[] A, double exponent)
 Calculate power on each sample of a complex array using the specified exponent More...
 
static double [] Power (Complex[] A)
 Returns the Power (absolute square) on each sample of a complex array More...
 
static double [] RadToDeg (double[] A)
 Convert a set of values representing radians into degrees More...
 
static T [] Range2< T > (T[] A, int start, int size)
 
static T [] Range< T > (T[] A, int start, int samples)
 Extract a range of samples from an array More...
 
static double [] Real (Complex[] A)
 Get the real part of a complex array More...
 
static Complex [] RealToComplex (double[] A)
 Converts a real array into a complex array More...
 
static double [] Reciprocal (double[] A)
 Returns the multiplicative inverse of a real array More...
 
static Complex [] Reciprocal (Complex[] A)
 Returns the multiplicative inverse of a complex array More...
 
static T [] Replicate< T > (T[] A, int times)
 Replicate an array by number of times More...
 
static T [] Reverse< T > (T[] A)
 Reverse the order of the samples in an array More...
 
static T [] RightShift< T > (T[] A, int samples, T value)
 Right shift an array by number of samples with value feed More...
 
static T [] Rotate< T > (T[] A, int samples)
 Rotate an array by number of samples More...
 
static double [] Round (double[] A, int decimals)
 Round the samples of a real array by the number of decimal digits More...
 
static Complex [] Round (Complex[] A, int decimals)
 Round the samples of a complex array by the number of decimal digits More...
 
static double [] SetInfinity (double[] A, double value)
 Replace any infinite values found on a real array with the specified real value More...
 
static Complex [] SetInfinity (Complex[] A, Complex c)
 Replace any infinite values found on a complex array with the specified complex value More...
 
static double [] SetNaN (double[] A, double value)
 Replace any NaN values found on a real array with the specified real value More...
 
static Complex [] SetNaN (Complex[] A, Complex c)
 Replace any NaN values found on a complex array with the specified complex value More...
 
static double [] Sin (double[] A)
 Calculate the sine on each sample of a real array More...
 
static Complex [] Sin (Complex[] A)
 Calculate the sine on each sample of a complex array More...
 
static double [] Sinh (double[] A)
 Calculate the hyperbolic sine on each sample of a real array More...
 
static Complex [] Sinh (Complex[] A)
 Calculate the hyperbolic sine on each sample of a complex array More...
 
static double [] Sort (double[] A)
 Sorts a set of real values in ascending order More...
 
static double [] Sqrt (double[] A)
 Calculate the square root on each sample of a real array More...
 
static Complex [] Sqrt (Complex[] A)
 Calculate the square root on each sample of a complex array More...
 
static T [] Sub< T > (T[] A, T[] B)
 Subtracts an array from another array More...
 
static T [] Sub< T > (T[] A, T value)
 Subtract all samples of an array with a value More...
 
static double [] Tan (double[] A)
 Calculate the tangent on each sample of a real array More...
 
static Complex [] Tan (Complex[] A)
 Calculate the tangent on each sample of a complex array More...
 
static double [] Tanh (double[] A)
 Calculate the hyperbolic tangent on each sample of a real array More...
 
static Complex [] Tanh (Complex[] A)
 Calculate the hyperbolic tangent on each sample of a complex array. More...
 
static double [] ToDouble (bool[] A)
 Convert boolean array into double array More...
 
static string ToString< T > (T[] A, string seperator)
 Converts an array into its string representation More...
 
static string ToString< T > (T[] A)
 Converts an array into its string representation More...
 
static bool [] XOR (params bool[][] args)
 XOR Gate Array More...
 

Properties

int Size [get]
 Gets the size of the NArray More...
 
this[int index] [get, set]
 Provides indexing in NArray More...
 

Detailed Description

Numeric array class provides a generic array data type and a usefull set of numeric array calculations.

Provides basic array calculations.

NArray supports many data types such as NArray<int>, NArray<double>, NArray<Complex>, etc.
Note: A class instance is a reference type, not a value type.

Template Parameters
Tspecified element data type

Constructor & Destructor Documentation

◆ NArray() [1/2]

dsp.NArray< T >.NArray ( T []  value)

Initialize a new instance of NArray class using another array

Narray is created with a reference in the provided array


Parameters
valuegeneric type array

Example 1

double[] d = new double[3]{1,2,3};
NArray<double> r = new NArray<double>(d);
Console.WriteLine(r);
1 2 3


Example 2

Assign of an array using the implicit operator.

double[] d = new double[3]{1,2,3};
NArray<double> r = d;
Console.WriteLine(r);
1 2 3

◆ NArray() [2/2]

dsp.NArray< T >.NArray ( int  size)

Initialize a new instance of NArray class


Parameters
sizesize of the array


Example 1
The following example creates an empty NArray with 3 items.
Each item is a double data type.

NArray<double> r = new NArray<double>(3);
Console.WriteLine(r);
0 0 0

Example 2
The following example instantiates NArray with default values.
Element type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
1 2 3

Member Function Documentation

◆ Abs()

static double [] dsp.NArray< T >.Abs ( double []  A)
static

Calculate the absolute value on each sample of a real array

◆ Acos() [1/2]

static double [] dsp.NArray< T >.Acos ( double []  A)
static

Calculate the arccosine on each sample of a real array

◆ Acos() [2/2]

static Complex [] dsp.NArray< T >.Acos ( Complex []  A)
static

Calculate the arcsine on each sample of a complex array

◆ Add()

void dsp.NArray< T >.Add ( arg)

Used internally for initialization upon declaration.

Do not use this method!

◆ Add< T >() [1/2]

static T [] dsp.NArray< T >.Add< T > ( params T  args[][])
static

Perform addition on multiple arrays

Parameters
argsarrays
Returns
$\displaystyle C_{i}=A_{i} + B_{i}$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Add(d,d);
Console.WriteLine(NArray.ToString(d));
2 4 6

◆ Add< T >() [2/2]

static T [] dsp.NArray< T >.Add< T > ( T []  A,
value 
)
static

Add all samples of an array with a specified value

Parameters
Aarray
valuescalar value
Returns
$\displaystyle C_{i}=A_{i} + value$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Add(d,1);
Console.WriteLine(NArray.ToString(d));
2 3 4

◆ AND()

static bool [] dsp.NArray< T >.AND ( params bool  args[][])
static

AND Gate

The AND gate is a boolean logic gate that returns True if all its inputs are True

◆ Asin() [1/2]

static double [] dsp.NArray< T >.Asin ( double []  A)
static

Calculate the arcsine on each sample of a real array

◆ Asin() [2/2]

static Complex [] dsp.NArray< T >.Asin ( Complex []  A)
static

Calculate the arccosine on each sample of a complex array

◆ Atan() [1/2]

static double [] dsp.NArray< T >.Atan ( double []  A)
static

Calculate the arctangent on each sample of a real array

◆ Atan() [2/2]

static Complex [] dsp.NArray< T >.Atan ( Complex []  A)
static

Calculate the arctangent on each sample of a complex array

◆ Atan2()

static double [] dsp.NArray< T >.Atan2 ( double []  A,
double []  B 
)
static

Calculate the arctangent using the quotient of two real arrays

◆ Clear()

void dsp.NArray< T >.Clear ( )

Clears all items of the NArray

Example

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
r.Clear();
Console.WriteLine(r);
1 2 3
0 0 0

◆ Conjugate()

static Complex [] dsp.NArray< T >.Conjugate ( Complex []  A)
static

Returns the complex conjugate of a complex array

Uses Complex.Conjugate

◆ Copy()

NArray<T> dsp.NArray< T >.Copy ( )

Copy method provides direct copy of all items of the current NArray to a new instance of the NArray class.

Example

NArray<double> r = new NArray<double>(3){1,2,3};
NArray<double> c = r.Copy();
Console.WriteLine(r==c);
True

◆ Cos() [1/2]

static double [] dsp.NArray< T >.Cos ( double []  A)
static

Calculate the cosine on each sample of a real array

◆ Cos() [2/2]

static Complex [] dsp.NArray< T >.Cos ( Complex []  A)
static

Calculate the cosine on each sample of a complex array

◆ Cosh() [1/2]

static double [] dsp.NArray< T >.Cosh ( double []  A)
static

Calculate the hyperbolic cosine on each sample of a real array

◆ Cosh() [2/2]

static Complex [] dsp.NArray< T >.Cosh ( Complex []  A)
static

Calculate the hyperbolic cosine on each sample of a complex array.

◆ DegToRad()

static double [] dsp.NArray< T >.DegToRad ( double []  A)
static

Convert a set of values representing degrees into radians

Parameters
Aarray with real values representng degrees

◆ Div< T >() [1/2]

static T [] dsp.NArray< T >.Div< T > ( T []  A,
T []  B 
)
static

Perform division using two arrays

Parameters
Aarray (divident)
Barray (divisor)
Returns
$\displaystyle C_{i}=A_{i} / B_{i}$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Div(d,d);
Console.WriteLine(NArray.ToString(d));
1 1 1

◆ Div< T >() [2/2]

static T [] dsp.NArray< T >.Div< T > ( T []  A,
value 
)
static

Divide all samples of an array with a the specified value

Parameters
Aarray (divident)
valuescalar value (divisor)
Returns
$\displaystyle C_{i}=A_{i} / value$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Div(d,2);
Console.WriteLine(NArray.ToString(d));
0.5 1 1.5

◆ Equals()

override bool dsp.NArray< T >.Equals ( object  obj)

◆ GetEnumerator()

IEnumerator dsp.NArray< T >.GetEnumerator ( )

Returns an enumerator that iterates through a collection.

◆ GetHashCode()

override int dsp.NArray< T >.GetHashCode ( )

◆ Img()

static double [] dsp.NArray< T >.Img ( Complex []  A)
static

Get the imaginary part of a complex array

Uses Complex.Img

◆ IsInfinity() [1/2]

static bool dsp.NArray< T >.IsInfinity ( double []  A)
static

Check if a real array contains a sample that has infinite value

◆ IsInfinity() [2/2]

static bool dsp.NArray< T >.IsInfinity ( Complex []  A)
static

Check if a complex array contains a sample that has infinite value

◆ IsNaN() [1/2]

static bool dsp.NArray< T >.IsNaN ( double []  A)
static

Check if a real array contains a sample that is not a number

◆ IsNaN() [2/2]

static bool dsp.NArray< T >.IsNaN ( Complex []  A)
static

Check if a complex array contains a sample that is not a number

◆ IsSizeEqual< T >()

static bool dsp.NArray< T >.IsSizeEqual< T > ( params T  args[][])
static

Check if the specified arrays have equal size

Parameters
argsarrays

◆ IsSizeEven< T >()

static bool dsp.NArray< T >.IsSizeEven< T > ( T []  A)
static

Check if an array has an even number of samples

Parameters
Aarray

◆ LeftShift< T >()

static T [] dsp.NArray< T >.LeftShift< T > ( T []  A,
int  samples,
value 
)
static

Left shift an array by number of samples with value feed

Shift amount must be less or equal the size of the array.

Parameters
Aarray
samplesshift amount
valuefeed value

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.LeftShift(d,1,0);
Console.WriteLine(NArray.ToString(d));
2 3 0

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.LeftShift<double>(r,1,0);
Console.WriteLine(r);
2 3 0

◆ Ln() [1/2]

static double [] dsp.NArray< T >.Ln ( double []  A)
static

Calculate the natural logarithm on each sample of a real array

◆ Ln() [2/2]

static Complex [] dsp.NArray< T >.Ln ( Complex []  A)
static

Calculate the natural logarithm on each sample of a complex array

◆ Log() [1/3]

static double [] dsp.NArray< T >.Log ( double []  A,
double  _base 
)
static

Calculate the logarithm on each sample of a real array using the specified base

◆ Log() [2/3]

static Complex [] dsp.NArray< T >.Log ( Complex []  A,
double  _base 
)
static

Calculate the logarithm on each sample of a complex array using a real base

◆ Log() [3/3]

static Complex [] dsp.NArray< T >.Log ( Complex []  A,
Complex  _base 
)
static

Calculate the logarithm on each sample of a complex array using a complex base

◆ Log10() [1/2]

static double [] dsp.NArray< T >.Log10 ( double []  A)
static

Calculate the logarithm of base10 on each sample of a real array

◆ Log10() [2/2]

static Complex [] dsp.NArray< T >.Log10 ( Complex []  A)
static

Calculate the logarithm of base10 on each sample of a complex array

◆ Magnitude()

static double [] dsp.NArray< T >.Magnitude ( Complex []  A)
static

Returns the magnitude (abs) on each sample of a complex array

Uses Complex.Magnitude

◆ MaxSize< T >()

static int dsp.NArray< T >.MaxSize< T > ( params T  args[][])
static

Returns the maximum size found on multiple arrays

Parameters
argsarrays

◆ Merge< T >()

static T [] dsp.NArray< T >.Merge< T > ( params T  args[][])
static

Concatenate multiple arrays

Parameters
argsarrays

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Merge(d,d);
Console.WriteLine(NArray.ToString(d));
1 2 3 1 2 3

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.Merge<double>(r,r);
Console.WriteLine(r);
1 2 3 1 2 3

◆ MinSize< T >()

static int dsp.NArray< T >.MinSize< T > ( params T  args[][])
static

Returns the minimum size found on multiple arrays

Parameters
argsarrays

◆ Mul< T >() [1/2]

static T [] dsp.NArray< T >.Mul< T > ( params T  args[][])
static

Perform multiplication on multiple arrays

Parameters
argsarrays
Returns
$\displaystyle C_{i}=A_{i} * B_{i}$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Mul(d,d);
Console.WriteLine(NArray.ToString(d));
1 4 9

◆ Mul< T >() [2/2]

static T [] dsp.NArray< T >.Mul< T > ( T []  A,
value 
)
static

Multiply all samples of an array with the specified value

Parameters
Aarray
valuescalar value
Returns
$\displaystyle C_{i}=A_{i} * value$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Mul(d,3);
Console.WriteLine(NArray.ToString(d));
3 6 9

◆ Negate< T >()

static T [] dsp.NArray< T >.Negate< T > ( T []  A)
static

Returns the additive reverse (opposite) of an array

Parameters
Aarray
Returns
$\displaystyle C_{i}=-A_{i}$

Example
Item type is double

double[] d = new double[3]{-1,2,3};
d = NArray.Negate(d);
Console.WriteLine(NArray.ToString(d));
1 -2 -3

◆ NOT()

static bool [] dsp.NArray< T >.NOT ( bool []  A)
static

NOT Gate

The NOT gate is a boolean logic gate that returns an inverted version of the input

◆ operator NArray< T >()

static implicit dsp.NArray< T >.operator NArray< T > ( T []  value)
static

Converts (implicitly) an array to NArray

Narray assigns a reference in the provided array


Parameters
valuegeneric type array


Example

double[] d = new double[3]{1,2,3};
NArray<double> r = d;
Console.WriteLine(r);
1 2 3

◆ operator T[]()

static implicit dsp.NArray< T >.operator T[] ( NArray< T >  value)
static

Converts (implicitly) a NArray to array

array assigns a reference in the provided NArray


Parameters
valuegeneric type NArray


Example 1

NArray<double> r = new NArray<double>(3){1,2,3};
double[] d = r;
Console.WriteLine(NArray.ToString(d));
1 2 3

◆ operator!=()

static bool dsp.NArray< T >.operator!= ( NArray< T >  A,
NArray< T >  B 
)
static

Inequality check of two NArray

Parameters
Afirst input NArray
Bsecond input NArray
Returns
$true \iff A \ne B $

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
NArray<double> c = r.Copy();
Console.WriteLine(r!=c);
False

◆ operator*() [1/2]

static NArray<T> dsp.NArray< T >.operator* ( NArray< T >  A,
NArray< T >  B 
)
static

Performs NArray multiplication

A and B should be of same size

Parameters
Afirst input NArray
Bsecond input NArray
Returns
$\displaystyle C_{i}=A_{i} * B_{i}$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r*r);
1 2 3
1 4 9

◆ operator*() [2/2]

static NArray<T> dsp.NArray< T >.operator* ( NArray< T >  A,
value 
)
static

Performs multiplication using a scalar

Parameters
Ainput NArray
valuescalar value
Returns
$\displaystyle C_{i}=A_{i} * value$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r*3);
1 2 3
3 6 9

◆ operator+() [1/2]

static NArray<T> dsp.NArray< T >.operator+ ( NArray< T >  A,
NArray< T >  B 
)
static

Performs NArray addition

A and B should be of same size

Parameters
Afirst input NArray
Bsecond input NArray
Returns
$\displaystyle C_{i}=A_{i} + B_{i}$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r+r);
1 2 3
2 4 6

◆ operator+() [2/2]

static NArray<T> dsp.NArray< T >.operator+ ( NArray< T >  A,
value 
)
static

Performs addition using a scalar

Parameters
Ainput NArray
valuescalar value
Returns
$\displaystyle C_{i}=A_{i} + value$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r+1);
1 2 3
2 3 4

◆ operator-() [1/3]

static NArray<T> dsp.NArray< T >.operator- ( NArray< T >  A,
NArray< T >  B 
)
static

Performs NArray subtraction

A and B should be of same size

Parameters
Afirst input NArray
Bsecond input NArray
Returns
$\displaystyle C_{i}=A_{i} - B_{i}$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r-r);
1 2 3
0 0 0

◆ operator-() [2/3]

static NArray<T> dsp.NArray< T >.operator- ( NArray< T >  A,
value 
)
static

Performs subtraction using a scalar

Parameters
Ainput NArray
valuescalar value
Returns
$\displaystyle C_{i}=A_{i} - value$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r-1);
1 2 3
0 1 2

◆ operator-() [3/3]

static NArray<T> dsp.NArray< T >.operator- ( NArray< T >  A)
static

Negates (opposite) all items in NArray

Parameters
Ainput NArray
Returns
$\displaystyle C_{i}=-A_{i}$

Example
Item type is double

NArray<double> r = new NArray<double>(3){-1,2,3};
Console.WriteLine(r);
Console.WriteLine(-r);
-1 2 3
1 -2 -3

◆ operator/() [1/2]

static NArray<T> dsp.NArray< T >.operator/ ( NArray< T >  A,
NArray< T >  B 
)
static

Performs NArray division

A and B should be of same size

Parameters
Afirst input NArray (dividend)
Bsecond input NArray (divisor)
Returns
$\displaystyle C_{i}=A_{i} / B_{i}$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r/r);
1 2 3
1 1 1

◆ operator/() [2/2]

static NArray<T> dsp.NArray< T >.operator/ ( NArray< T >  A,
value 
)
static

Performs division using a scalar

Parameters
Ainput NArray (divident)
valuescalar value (divisor)
Returns
$\displaystyle C_{i}=A_{i} / value$

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
Console.WriteLine(r/2);
1 2 3
0.5 1 1.5

◆ operator==()

static bool dsp.NArray< T >.operator== ( NArray< T >  A,
NArray< T >  B 
)
static

Equality check of two NArray

Parameters
Afirst input NArray
Bsecond input NArray
Returns
$true \iff A=B $

Example
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
NArray<double> c = r.Copy();
Console.WriteLine(r==c);
True

◆ OR()

static bool [] dsp.NArray< T >.OR ( params bool  args[][])
static

OR Gate

The OR gate is a boolean logic gate that returns True if one or more of its inputs are True

◆ Padd< T >()

static T [] dsp.NArray< T >.Padd< T > ( T []  A,
int  samples,
value 
)
static

Padd an array by number of samples using value fill

Parameters
Aarray
samplespadded size
valuepadded value

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Padd(d,2,0);
Console.WriteLine(NArray.ToString(d));
1 2 3 0 0

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.Padd<double>(r,2,0);
Console.WriteLine(r);
1 2 3 0 0

◆ PaddRadix2< T >()

static T [] dsp.NArray< T >.PaddRadix2< T > ( T []  A,
value 
)
static

Padd an array till size reach a power of two using value fill

If input size N is a power of 2 a copy of the array is returned.

Parameters
Aarray
valuepadded value

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.PaddRadix2(d,0);
Console.WriteLine(NArray.ToString(d));
1 2 3 0

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.PaddRadix2<double>(r,0);
Console.WriteLine(r);
1 2 3 0

◆ Phase()

static double [] dsp.NArray< T >.Phase ( Complex []  A)
static

Returns the phase in radians on each sample of a complex array

Uses Complex.Phase

◆ PolarToRec()

static Complex [] dsp.NArray< T >.PolarToRec ( double []  A_mag,
double []  A_phase 
)
static

Polar-to-Rectangular array conversion

Uses Complex.PolarToRec

◆ Pow() [1/3]

static double [] dsp.NArray< T >.Pow ( double []  A,
double  exponent 
)
static

Calculate power on each sample of a real array using the specified exponent

◆ Pow() [2/3]

static double [] dsp.NArray< T >.Pow ( double []  A,
int  exponent 
)
static

Calculate power on each sample of a real array using the specified exponent

◆ Pow() [3/3]

static Complex [] dsp.NArray< T >.Pow ( Complex []  A,
double  exponent 
)
static

Calculate power on each sample of a complex array using the specified exponent

◆ Power()

static double [] dsp.NArray< T >.Power ( Complex []  A)
static

Returns the Power (absolute square) on each sample of a complex array

Uses Complex.Power

◆ RadToDeg()

static double [] dsp.NArray< T >.RadToDeg ( double []  A)
static

Convert a set of values representing radians into degrees

Parameters
Aarray with real values representing radians

◆ Range2< T >()

static T [] dsp.NArray< T >.Range2< T > ( T []  A,
int  start,
int  size 
)
static

◆ Range< T >()

static T [] dsp.NArray< T >.Range< T > ( T []  A,
int  start,
int  samples 
)
static

Extract a range of samples from an array

Parameters
Aarray
startindex to start the range (zero based)
samplesrange size

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Range(d,1,2);
Console.WriteLine(NArray.ToString(d));
2 3

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.Range<double>(r,1,2);
Console.WriteLine(r);
2 3

◆ Real()

static double [] dsp.NArray< T >.Real ( Complex []  A)
static

Get the real part of a complex array

Uses Complex.Real

◆ RealToComplex()

static Complex [] dsp.NArray< T >.RealToComplex ( double []  A)
static

Converts a real array into a complex array

◆ Reciprocal() [1/2]

static double [] dsp.NArray< T >.Reciprocal ( double []  A)
static

Returns the multiplicative inverse of a real array

◆ Reciprocal() [2/2]

static Complex [] dsp.NArray< T >.Reciprocal ( Complex []  A)
static

Returns the multiplicative inverse of a complex array

◆ Replicate< T >()

static T [] dsp.NArray< T >.Replicate< T > ( T []  A,
int  times 
)
static

Replicate an array by number of times

Parameters
Aarray
timesreplication amount

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Replicate(d,2);
Console.WriteLine(NArray.ToString(d));
1 2 3 1 2 3

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.Replicate<double>(r,2);
Console.WriteLine(r);
1 2 3 1 2 3

◆ Reverse< T >()

static T [] dsp.NArray< T >.Reverse< T > ( T []  A)
static

Reverse the order of the samples in an array

Parameters
Aarray

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Reverse(d);
Console.WriteLine(NArray.ToString(d));
3 2 1

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.Reverse<double>(r);
Console.WriteLine(r);
3 2 1

◆ RightShift< T >()

static T [] dsp.NArray< T >.RightShift< T > ( T []  A,
int  samples,
value 
)
static

Right shift an array by number of samples with value feed

Shift amount must be less or equal the size of the array.

Parameters
Aarray
samplesshift amount
valuefeed value

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.RightShift(d,1,0);
Console.WriteLine(NArray.ToString(d));
0 1 2

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.RightShift<double>(r,1,0);
Console.WriteLine(r);
0 1 2

◆ Rotate< T >()

static T [] dsp.NArray< T >.Rotate< T > ( T []  A,
int  samples 
)
static

Rotate an array by number of samples

Rotational amount must be less or equal the size of the array.
By default a right rotation is returned, however left rotation can be accomplished by subtracting from the array's length the desired amount.

Parameters
Aarray
samplesright rotation amount

Example 1
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Rotate(d,1);
Console.WriteLine(NArray.ToString(d));
3 1 2

Example 2
Item type is double

NArray<double> r = new NArray<double>(3){1,2,3};
r = NArray.Rotate<double>(r,1);
Console.WriteLine(r);
3 1 2

◆ Round() [1/2]

static double [] dsp.NArray< T >.Round ( double []  A,
int  decimals 
)
static

Round the samples of a real array by the number of decimal digits

◆ Round() [2/2]

static Complex [] dsp.NArray< T >.Round ( Complex []  A,
int  decimals 
)
static

Round the samples of a complex array by the number of decimal digits

◆ SetInfinity() [1/2]

static double [] dsp.NArray< T >.SetInfinity ( double []  A,
double  value 
)
static

Replace any infinite values found on a real array with the specified real value

◆ SetInfinity() [2/2]

static Complex [] dsp.NArray< T >.SetInfinity ( Complex []  A,
Complex  c 
)
static

Replace any infinite values found on a complex array with the specified complex value

◆ SetNaN() [1/2]

static double [] dsp.NArray< T >.SetNaN ( double []  A,
double  value 
)
static

Replace any NaN values found on a real array with the specified real value

◆ SetNaN() [2/2]

static Complex [] dsp.NArray< T >.SetNaN ( Complex []  A,
Complex  c 
)
static

Replace any NaN values found on a complex array with the specified complex value

◆ Sin() [1/2]

static double [] dsp.NArray< T >.Sin ( double []  A)
static

Calculate the sine on each sample of a real array

◆ Sin() [2/2]

static Complex [] dsp.NArray< T >.Sin ( Complex []  A)
static

Calculate the sine on each sample of a complex array

◆ Sinh() [1/2]

static double [] dsp.NArray< T >.Sinh ( double []  A)
static

Calculate the hyperbolic sine on each sample of a real array

◆ Sinh() [2/2]

static Complex [] dsp.NArray< T >.Sinh ( Complex []  A)
static

Calculate the hyperbolic sine on each sample of a complex array

◆ Sort()

static double [] dsp.NArray< T >.Sort ( double []  A)
static

Sorts a set of real values in ascending order

◆ Sqrt() [1/2]

static double [] dsp.NArray< T >.Sqrt ( double []  A)
static

Calculate the square root on each sample of a real array

◆ Sqrt() [2/2]

static Complex [] dsp.NArray< T >.Sqrt ( Complex []  A)
static

Calculate the square root on each sample of a complex array

◆ Sub< T >() [1/2]

static T [] dsp.NArray< T >.Sub< T > ( T []  A,
T []  B 
)
static

Subtracts an array from another array

Parameters
Aarray
Barray
Returns
$\displaystyle C_{i}=A_{i} - B_{i}$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Sub(d,d);
Console.WriteLine(NArray.ToString(d));
0 0 0

◆ Sub< T >() [2/2]

static T [] dsp.NArray< T >.Sub< T > ( T []  A,
value 
)
static

Subtract all samples of an array with a value

Parameters
Aarray
valuescalar value
Returns
$\displaystyle C_{i}=A_{i} - value$

Example
Item type is double

double[] d = new double[3]{1,2,3};
d = NArray.Sub(d,1);
Console.WriteLine(NArray.ToString(d));
0 1 2

◆ Tan() [1/2]

static double [] dsp.NArray< T >.Tan ( double []  A)
static

Calculate the tangent on each sample of a real array

◆ Tan() [2/2]

static Complex [] dsp.NArray< T >.Tan ( Complex []  A)
static

Calculate the tangent on each sample of a complex array

◆ Tanh() [1/2]

static double [] dsp.NArray< T >.Tanh ( double []  A)
static

Calculate the hyperbolic tangent on each sample of a real array

◆ Tanh() [2/2]

static Complex [] dsp.NArray< T >.Tanh ( Complex []  A)
static

Calculate the hyperbolic tangent on each sample of a complex array.

◆ ToDouble()

static double [] dsp.NArray< T >.ToDouble ( bool []  A)
static

Convert boolean array into double array

Parameters
ABoolean array
Returns
Returns 1 if sample value is True, else 0

◆ ToString()

override string dsp.NArray< T >.ToString ( )

Converts the NArray to its string representation

Converted string is in clear and printable form.
The function NArray.Round can be used to aid clarity

Example

NArray<double> r = new NArray<double>(3){1,2,3};
Console.WriteLine(r);
1 2 3

◆ ToString< T >() [1/2]

static string dsp.NArray< T >.ToString< T > ( T []  A,
string  seperator 
)
static

Converts an array into its string representation

Parameters
Aarray
seperatorvalue separator

Example 1
using comma separated value

double[] d = new double[3]{1,2,3};
Console.WriteLine(NArray.ToString(d, ", "));
1, 2, 3

Example 2
using a line break to separate values

double[] d = new double[3]{1,2,3};
Console.WriteLine(NArray.ToString(d, "\n"));
1
2
3

◆ ToString< T >() [2/2]

static string dsp.NArray< T >.ToString< T > ( T []  A)
static

Converts an array into its string representation

Each value in the converted string is separated by 3 spaces.
The function NArray.Round can be used to aid clarity if there many decimal digits.

Parameters
Aarray

Example

double[] d = new double[3]{1,2,3};
Console.WriteLine(NArray.ToString(d));
1 2 3

◆ XOR()

static bool [] dsp.NArray< T >.XOR ( params bool  args[][])
static

XOR Gate Array

The XOR gate is a boolean logic gate that returns True if either, but not both, of its two inputs are True. For more than two inputs XOR is performed sequentially.

Property Documentation

◆ Size

int dsp.NArray< T >.Size
get

Gets the size of the NArray

Example

NArray<double> r = new NArray<double>(3);
Console.WriteLine(r.Size);
3

◆ this[int index]

T dsp.NArray< T >.this[int index]
getset

Provides indexing in NArray

Can be used to get and set an item


Parameters
indexitem index (zero based)


Example Item type is double

NArray<double> r = new NArray<double>(3);
r[1] = 1;
Console.WriteLine(r);
0 1 0