Package JSci.maths

Examples of JSci.maths.Complex


    public double[] powerSpectrum(final double[] arrFunc) throws IllegalArgumentException {
        AbstractComplexVector   vecSpec = this.transform(arrFunc);
       
        double[]    arrSpec = new double[this.getDataSize()];
        for (int index=0; index<this.getDataSize(); index++)    {
            Complex cpxVal = vecSpec.getComponent(index);
            arrSpec[index] = cpxVal.modSqr();
        }

        return arrSpec;
    }
View Full Code Here


        final int           N = szData;             // vector/matrix dimensions

       
        // Compute the z transform generator
        Double               h = 2.0*Math.PI/N;
        Complex              z = new Complex(Math.cos(h), Math.sin(h));
      

        // Create matrix kernel and compute element values
        final double         c = Math.sqrt(1.0/N);   // normalization constant
        ComplexSquareMatrix  Kf = new ComplexSquareMatrix( N );
View Full Code Here

        final int           N = szData;             // vector/matrix dimensions

       
        // Compute the z transform generator
        Double               h  = 2.0*Math.PI/N;
        Complex              zf = new Complex(Math.cos(h), -Math.sin(h));
        Complex              zi = new Complex(Math.cos(h), Math.sin(h));
      

        // Create matrix kernel and compute element values
        final double         c = Math.sqrt(1.0/N);   // normalization constant
        ComplexSquareMatrix  Kf = new ComplexSquareMatrix( N );
        ComplexSquareMatrix  Ki = new ComplexSquareMatrix( N );
       
        Complex     kf, ki;     // matrix kernel element values
        Complex     zfm = Complex.ONE;
        Complex     zim = Complex.ONE;
        for (int m=0; m<N; m++)    {

            kf = zfm.multiply(c);
            ki = zim.multiply(c);
           
            for (int n=m; n<N; n++)    {
                Kf.setElement(m, n, kf);
                Kf.setElement(n, m, kf);
               
                Ki.setElement(m, n, ki);
                Ki.setElement(n, m, ki);

                kf = kf.multiply(zfm);
                ki = ki.multiply(zim);
            }
           
            zfm = zfm.multiply(zf);
            zim = zim.multiply(zi);
        }
       
        this.szData = N;
        this.cpxZ   = zi;
        this.matKerFwd = Kf;
View Full Code Here

     * @param   z   Z-transform variable (lies on the unit circle)
     *
     * @return      value of this filter's transfer function at z
     */
    public Complex  transferFunction(Complex z) {
        Complex cpxZpwr  = Complex.ONE;     // power of z
        Complex cpxDenom = Complex.ZERO;   // transfer function denominator
        Complex cpxNumer = Complex.ZERO;   // transfer function numerator
       
        for (int index=0; index<this.getCoefficientSize(); index++)    {
            double  a = this.arrCoefInp[index];
            double  b = this.arrCoefOut[index];
           
            cpxNumer = cpxNumer.add( cpxZpwr.multiply(a) );
            cpxDenom = cpxDenom.add( cpxZpwr.multiply(b) );
           
            cpxZpwr  = cpxZpwr.divide(z);
        }
       
        return cpxNumer.divide(cpxDenom);
    }
View Full Code Here

     * @param   z   Z-transform variable (lies on the unit circle)
     *
     * @return      value of this filter's transfer function at z
     */
    public Complex  transferFunction(Complex z) {
        Complex cpxZpwr  = Complex.ONE;     // power of z
        Complex cpxDenom = Complex.ZERO;   // transfer function denominator
        Complex cpxNumer = Complex.ZERO;   // transfer function numerator
       
        for (int iDelay=0; iDelay<this.getCoefficientCount(); iDelay++)    {
            double  a = this.arrCoefInp[iDelay];
            double  b = this.arrCoefOut[iDelay];
           
            cpxNumer = cpxNumer.add( cpxZpwr.multiply(a) );
            cpxDenom = cpxDenom.add( cpxZpwr.multiply(b) );
           
            cpxZpwr  = cpxZpwr.divide(z);
        }
       
        return cpxNumer.divide(cpxDenom);
    }
View Full Code Here

            this.clearFreqComponent(index, vecTrans);

        // Attenuate the pass-band
        for (int index=1; index<intFreq; index++)   {
            double      dblH = (1.0*index)/intFreq;
            Complex     cpxA = new Complex(1.0 - dblH*dblH, 0.0);

            this.amplifyFreqComponent(index, cpxA, vecTrans);
        }

        //        // Correct the phasing
View Full Code Here

     * @param vecTrans      transform function
     */
    private void amplifyFreqComponent(int intFreq, Complex cpxA, AbstractComplexVector vecTrans) {
        int     N = this.getDataSize();
       
        Complex cpxSpec;
       
        cpxSpec = vecTrans.getComponent(intFreq);
        vecTrans.setComponent(intFreq, cpxSpec.multiply(cpxA));

        if (intFreq == 0) return;
        cpxSpec = vecTrans.getComponent(N - intFreq);
        vecTrans.setComponent(N - intFreq, cpxSpec.multiply(cpxA));
    }
View Full Code Here

       
        for (int iFreq=0; iFreq<N; iFreq++) {
            double  cos = Math.cos(iFreq*h);
            double  sin = Math.sin(iFreq*h);

            Complex cpxPhase = new Complex(cos, -sin);
            Complex cpxSpec  = vecTrans.getComponent(iFreq);
            vecTrans.setComponent(iFreq, cpxSpec.multiply(cpxPhase));
        }
    }
View Full Code Here

TOP

Related Classes of JSci.maths.Complex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.