package org.madore.ephem; import java.util.List; import java.util.HashMap; import java.util.Arrays; public final class Comput { public static final double degree = Math.PI/180; public static final double arcsecond = degree/3600; 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 SumPoisson2Terms(List tms) { super(tms); this.tms = tms; } public SumPoisson2Terms(Poisson2Term[] tms) { this(Arrays.asList(tms)); } public double v(double t) { double z = 0; final int npow = 6; double[] tpow = new double[npow]; for ( int d=0 ; d fncache = new HashMap(); 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; double[] tpow = new double[npow]; for ( int d=0 ; d