Vector.DCT Method

Overload List

#SignatureDescription
1TVec DCTThe forward discrete cosine transform (DCT).
2TVec DCT(TVec Vec)Calculates the forward discrete cosine transform (DCT) of the Vec.
3TMtxVec DCT(TMtxVec Vec, Int32 VecIndex, Int32 Index, Int32 Len)The forward discrete cosine transform (DCT).

Overload 1: TVec DCT

The forward discrete cosine transform (DCT).

Result: stored in self (calling object), returns self for chaining

Remarks:

Calculates the forward discrete cosine transform (DCT) of all calling vector elements in-place. If vector Dew.Math.Vector.Length is a power of 2, the function uses an efficient algorithm that is significantly faster than the direct computation of DCT. For different lengths this function uses the direct formulas given below; however, the symmetry of cosine function is taken into account, which allows to perform about half of the multiplication operations in the formulas. In the following definition of DCT, N=Vec.Length and V is the calling vector:

C(k)={1Nk=02Nk>0V[k]=C(k)n=0N1Vec[n]cos((2n+1)kπ2N)\begin{aligned} C(k) &= \begin{cases} \sqrt{\frac{1}{N}} & k=0 \\ \sqrt{\frac{2}{N}} & k > 0 \end{cases} \\ \text{V}[k] &= C(k)\cdot \sum _{n=0} ^{N-1} \text{Vec}[n]\cdot \cos \left( \frac{(2n+1)k\pi}{2N}\right) \end{aligned}
Examples
Vector a;
Vector b;
a.SetIt(false,new double[] {1,-2,3,4});
b.DCT(a);
See Also: Vector.IDCT, Vector.FFT

Overload 2: TVec DCT(TVec Vec)

Calculates the forward discrete cosine transform (DCT) of the Vec.

#NameTypeDescription
1VecTVecsource TVec

Result: stored in self (calling object), returns self for chaining

Remarks:

Writes the result in the calling vector. If Vec.Length is a power of 2, the function uses an efficient algorithm that is significantly faster than the direct computation of DCT. For other values of Vec Length, this function uses the direct formulas.

Overload 3: TMtxVec DCT(TMtxVec Vec, Int32 VecIndex, Int32 Index, Int32 Len)

The forward discrete cosine transform (DCT).

#NameTypeDescription
1VecTMtxVecsource TVec or TMtx
2VecIndexInt32
3IndexInt32start index
4LenInt32element count

Result: stored in self (calling object), returns self for chaining

Remarks:

Calculates the forward discrete cosine transform (DCT) of the Vec and writes the result in the calling vector. If Vec.Length is a power of 2, the function uses an efficient algorithm that is significantly faster than the direct computation of DCT. For other values of Vec Length, this function uses the direct formulas given below; however, the symmetry of cosine function is taken into account, which allows to perform about half of the multiplication operations in the formulas. In the following definition of DCT, N=Vec.Length and V is the calling vector:

C(k)={1Nk=02Nk>0V[k]=C(k)n=0N1Vec[n]cos((2n+1)kπ2N)\begin{aligned} C(k) &= \begin{cases} \sqrt{\frac{1}{N}} & k=0 \\ \sqrt{\frac{2}{N}} & k > 0 \end{cases} \\ \text{V}[k] &= C(k)\cdot \sum _{n=0} ^{N-1} \text{Vec}[n]\cdot \cos \left( \frac{(2n+1)k\pi}{2N}\right) \end{aligned}
Examples
Vector a;
Vector b;
a.SetIt(false,new double[] {1,-2,3,4});
b.DCT(a);
See Also: Vector.IDCT, Vector.FFT