From d64c37f6f24abbfb7e02b8f9ea670a9b5e794f2e Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Sat, 24 Mar 2012 00:54:50 +0100 Subject: Initial commit. This version doesn't do much but evaluate VSOP87/Smart97 series. --- org/madore/ephem/Comput.java | 195 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 org/madore/ephem/Comput.java (limited to 'org/madore/ephem/Comput.java') diff --git a/org/madore/ephem/Comput.java b/org/madore/ephem/Comput.java new file mode 100644 index 0000000..dee77f0 --- /dev/null +++ b/org/madore/ephem/Comput.java @@ -0,0 +1,195 @@ +package org.madore.ephem; + +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; + +public final class Comput { + + public static final double ipow(double x, int n) { + if ( n == 0 ) + return 1; + else if ( n == 1 ) + return x; + else if ( n < 0 ) { + x = 1./x; + n = -n; + } + double y = x; + int k = 1; + double z = 1; + int m = 0; + while ( true ) { + if ( ( n & k ) != 0 ) { + z *= y; + m += k; + } + if ( m < n ) { + y *= y; + k *= 2; + } else + return z; + } + } + + private static Double[] boxDoubleArray(double[] c) { + Double[] boxed = new Double[c.length]; + for ( int i=0 ; i tms; + public SumFunction(List tms) { + this.tms = tms; + } + public SumFunction(Function[] tms) { + this(Arrays.asList(tms)); + } + public double v(double t) { + double z = 0; + for ( int i=0 ; i c; + List tms; + public LinCombFunction(List c, List tms) { + if ( c.size() != tms.size() ) + throw new IllegalArgumentException(); + this.c = c; + this.tms = tms; + } + public LinCombFunction(List c, Function[] tms) { + this(c, Arrays.asList(tms)); + } + public LinCombFunction(Double[] c, List tms) { + this(Arrays.asList(c), tms); + } + public LinCombFunction(Double[] c, Function[] tms) { + this(Arrays.asList(c), Arrays.asList(tms)); + } + public LinCombFunction(double[] c, List tms) { + this(boxDoubleArray(c), tms); + } + public LinCombFunction(double[] c, Function[] tms) { + this(boxDoubleArray(c), tms); + } + public double v(double t) { + double z = 0; + for ( int i=0 ; i c; + public Polynomial(List c) { + this.c = c; + } + public Polynomial(Double[] c) { + this(Arrays.asList(c)); + } + public Polynomial(double[] c) { + this(boxDoubleArray(c)); + } + public double v(double t) { + double z = 0; + double y = 1; + for ( int i=0 ; i tms; + public SumPoissonTerms(List tms) { + super(tms); + this.tms = tms; + } + public SumPoissonTerms(PoissonTerm[] tms) { + this(Arrays.asList(tms)); + } + public double v(double t) { + double z = 0; + final int npow = 6; + List tpow = new ArrayList(npow); + for ( int d=0 ; d