@@ -0,0 +1,3066 @@
+/*%0A * Zorbage: an algebraic data hierarchy for use in numeric processing.%0A *%0A * Copyright (c) 2016-2022 Barry DeZonia All rights reserved.%0A * %0A * Redistribution and use in source and binary forms, with or without modification,%0A * are permitted provided that the following conditions are met:%0A * %0A * Redistributions of source code must retain the above copyright notice, this list%0A * of conditions and the following disclaimer.%0A * %0A * Redistributions in binary form must reproduce the above copyright notice, this%0A * list of conditions and the following disclaimer in the documentation and/or other%0A * materials provided with the distribution.%0A * %0A * Neither the name of the %3Ccopyright holder%3E nor the names of its contributors may%0A * be used to endorse or promote products derived from this software without specific%0A * prior written permission.%0A * %0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22 AND%0A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED%0A * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.%0A * IN NO EVENT SHALL %3CCOPYRIGHT HOLDER%3E BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,%0A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR%0A * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN%0A * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN%0A * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH%0A * DAMAGE.%0A */%0Apackage nom.bdezonia.zorbage.algorithm;%0A%0Aimport nom.bdezonia.zorbage.algebra.Algebra;%0Aimport nom.bdezonia.zorbage.algebra.Invertible;%0Aimport nom.bdezonia.zorbage.algebra.Multiplication;%0Aimport nom.bdezonia.zorbage.algebra.Unity;%0Aimport nom.bdezonia.zorbage.datasource.IndexedDataSource;%0A%0A/**%0A * %0A * @author Barry DeZonia%0A *%0A */%0Apublic class ZTransform %7B%0A%0A%09// do not instantiate%0A%09%0A%09private ZTransform() %7B %7D%0A%0A%09/**%0A%09 * Do a Z transform of an input data list into an output data list. Passing one%0A%09 * list as both input and output is allowed. Note that it is assumed that all%0A%09 * radius of convergence limitations have already been considered before passing%0A%09 * data into this code.%0A%09 * %0A%09 * @param %3CCA%3E%0A%09 * @param %3CC%3E%0A%09 * @param cAlg The (complex or real or other) algebra to use for math operations.%0A%09 * @param z The z value to scale terms by.%0A%09 * @param a The input list of values (usually complex but could be other).%0A%09 * @param b The output list of values (usually complex but could be other).%0A%09 */%0A%09public static %3CCA extends Algebra%3CCA,C%3E & Multiplication%3CC%3E & Invertible%3CC%3E & Unity%3CC%3E,%0A%09%09%09%09%09C%3E%0A%09%09void compute(CA cAlg, C z, IndexedDataSource%3CC%3E a, IndexedDataSource%3CC%3E b)%0A%09%7B%0A%09%09C scale = cAlg.construct();%0A%09%09C tmp = cAlg.construct();%0A%09%09cAlg.unity().call(scale);%0A%09%09long N = a.size();%0A%09%09for (long i = 0; i %3C N; i++) %7B%0A%09%09%09a.get(i, tmp);%0A%09%09%09cAlg.multiply().call(tmp, scale, tmp);%0A%09%09%09b.set(i, tmp);%0A%09%09%09cAlg.divide().call(scale, z, scale);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Define a simple Z Transform algorithm