Click here to Skip to main content
15,880,956 members
Articles / Web Development / HTML

Discrete Wavelet Transforms, a Java Implementation

Rate me:
Please Sign up or sign in to vote.
4.95/5 (16 votes)
13 Nov 2014CPOL10 min read 60.4K   5.6K   19  
This article presents a Java example application that performs discrete wavelet transforms.
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * $Id: TestSuite.java,v 1.47 2004/03/16 15:51:25 metlov Exp $
 *
 * This file is part of the Java Expressions Library (JEL).
 *
 * (c) 1998 -- 2007 by Konstantin L. Metlov
 *
 * JEL is Distributed under the terms of GNU General Public License.
 *    This code comes with ABSOLUTELY NO WARRANTY.
 *  For license details see COPYING file in this directory.
 */

package gnu.jel;

import gnu.jel.tests.*;
import java.io.PrintStream;
import java.util.Stack;

public class IntegralDotOperatorTest extends TestingUtils {
  public IntegralDotOperatorTest(String name) {
    super(name);
  }

  Library lib;
  Object[] rtp;
  VariableProvider vp;

  public void setUp() throws Exception {
    Class[] dynamicLib=new Class[1];
    rtp=new Object[1];
    vp=new VariableProvider();
    Class[] staticLib=new Class[2];
    staticLib[0]=Class.forName("java.lang.Math");
    // next line makes also static functions from VariablePrivider available
    staticLib[1]=vp.getClass();  
    vp.xvar=5.0;
    vp.strVar="strVar";
    rtp[0]=vp;
    dynamicLib[0]=vp.getClass();

    Class[] dotLib=new Class[5];
    dotLib[0]=Class.forName("java.lang.String");
    dotLib[1]=Class.forName("java.lang.Double");
    dotLib[2]=Class.forName("gnu.jel.reflect.Double");
    dotLib[3]=IntegerObject.class;
    dotLib[4]=DoubleObject.class;
    lib=new Library(staticLib,dynamicLib,dotLib,null,null);
  }
  
  
  public void test1() throws Throwable {
    simExpression("(\"abc\").length()", new Integer(3), null, rtp, lib,null);
  }

  public void test2() throws Throwable {
    simExpression("\"abc\".length()", new Integer(3), null, rtp, lib,null);
  }

  public void test3() throws Throwable {
    simExpression("strVar.length()", new Integer(6), null, rtp, lib,null);
  }

  public void test4() throws Throwable {
    simExpression("\"abc\".endsWith(\"bc\")", Boolean.TRUE, null, rtp, lib,null);
  }

  public void test5() throws Throwable {
    simExpression("\"abc\".compareTo(\"bc\")", new Integer(-1), null, rtp, lib,null);
  }

  public void test6() throws Throwable {
    simExpression("\"abcdbc\".indexOf(\"bc\")", new Integer(1), null, rtp, lib,null);
  }

  public void test7() throws Throwable {
    simExpression("\"abcdbc\".indexOf(\"abc\".substring(1),2)", new Integer(4), null, rtp, lib,null);
  }

  public void test8() throws Throwable {
    simError("\"abc\".nomethod()",null,lib,7,null);
  }

  public void test9() throws Throwable {
    simError("\"abc\".length(666)",null,lib,7,null);
  }

  public void test10() throws Throwable {
    simError("2.0.doubleValue()",null,lib,4,null);
  }

  public void test11() throws Throwable {
    simExpression("intObj+1", new Integer(556), null, rtp, lib,null);
  }

  public void test12() throws Throwable {
    simExpression("(int)intObj", new Integer(555), null, rtp, lib,null);
  }

  public void test13() throws Throwable {
    simExpression("arr[intObj-554]", new Double(5.0), null, rtp, lib,null);
  }

  public void test14() throws Throwable {
    simExpression("arr[max(intObj-554,0)]", new Double(5.0), null, rtp, lib,null);
  }

  public void test15() throws Throwable {
    simExpression("arr[max(intObj,0)-554]", new Double(5.0), null, rtp, lib,null);
  }

  public void test16() throws Throwable {
    simExpression("arr[byteObj]", new Double(6.0), null, rtp, lib,null);
  }

  public void test17() throws Throwable {
    simExpression("byteObj+1.0", new Double(3.0), null, rtp, lib,null);
  }

  public void test18() throws Throwable {
    simExpression("arrDoubleJELObj1[0].getValue()+"+
                   "arrDoubleJELObj1[1].getValue()",
                   new Double(3.0), null, rtp, lib,null);
  }
  
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder PEI Watershed Alliance, Inc.
United States United States
I am an analytical chemist and an educator. I program primarily to perform matrix computations for regression analysis, process signals, acquire data from sensors, and to control devices.

I participate in many open source development communities and Linux user forums. I do contract work for an environmental analytical laboratory, where I am primarily focused on LIMS programming and network administration.

I am a member of several community-interest groups such as the Prince Edward Island Watershed Alliance, the Lot 11 and Area Watershed Management Group, and the Petersham Historic Commission.

Comments and Discussions