source: src/main/java/agents/anac/y2015/agentBuyogV2/flanagan/interpolation/BiCubicSplineShort.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 4.5 KB
Line 
1/**********************************************************
2*
3* BiCubicSplineShort.java (Deprecated)
4*
5* See Class BiCubicSplineFast for replacement class
6* This class has been retained purely for compatibility purposes
7* and will not be updated
8*
9* Class for performing an interpolation on the tabulated
10* function y = f(x1,x2) using a natural bicubic spline
11* Assumes second derivatives at end points = 0 (natural spine)
12* Stripped down version of BiCubicSpline - all data checks have been removed for faster running
13*
14* WRITTEN BY: Dr Michael Thomas Flanagan
15*
16* DATE: 26 December 2009 (Stripped down version of BiCubicSpline: May 2002 - 31 October 2009)
17* DEPRECATED: 31 December 2009
18*
19* DOCUMENTATION:
20* See Michael Thomas Flanagan's Java library on-line web page:
21* http://www.ee.ucl.ac.uk/~mflanaga/java/BiCubicSplineShort.html
22* http://www.ee.ucl.ac.uk/~mflanaga/java/
23*
24* Copyright (c) 2002 - 2009 Michael Thomas Flanagan
25*
26* PERMISSION TO COPY:
27*
28* Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee,
29* provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies
30* and associated documentation or publications.
31*
32* Redistributions of the source code of this source code, or parts of the source codes, must retain the above copyright notice, this list of conditions
33* and the following disclaimer and requires written permission from the Michael Thomas Flanagan:
34*
35* Redistribution in binary form of all or parts of this class must reproduce the above copyright notice, this list of conditions and
36* the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission from the Michael Thomas Flanagan:
37*
38* Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose.
39* Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software
40* or its derivatives.
41*
42***************************************************************************************/
43
44package agents.anac.y2015.agentBuyogV2.flanagan.interpolation;
45
46public class BiCubicSplineShort{
47
48 private int nPoints = 0; // no. of x1 tabulated points
49 private int mPoints = 0; // no. of x2 tabulated points
50 private double[][] y = null; // y=f(x1,x2) tabulated function
51 private double[] x1 = null; // x1 in tabulated function f(x1,x2)
52 private double[] x2 = null; // x2 in tabulated function f(x1,x2)
53 private CubicSplineShort csn[] = null; // nPoints array of CubicSpline instances
54 private CubicSplineShort csm = null; // CubicSpline instance
55
56
57 // Constructor
58 // Constructor with data arrays initialised to arrays x and y
59 public BiCubicSplineShort(double[] x1, double[] x2, double[][] y){
60 this.nPoints=x1.length;
61 this.mPoints=x2.length;
62
63 this.csm = new CubicSplineShort(this.nPoints);
64 this.csn = CubicSplineShort.oneDarray(this.nPoints, this.mPoints);
65 this.x1 = new double[this.nPoints];
66 this.x2 = new double[this.mPoints];
67 this.y = new double[this.nPoints][this.mPoints];
68 for(int i=0; i<this.nPoints; i++){
69 this.x1[i]=x1[i];
70 }
71 for(int j=0; j<this.mPoints; j++){
72 this.x2[j]=x2[j];
73 }
74 for(int i =0; i<this.nPoints; i++){
75 for(int j=0; j<this.mPoints; j++){
76 this.y[i][j]=y[i][j];
77 }
78 }
79
80 double[] yTempn = new double[mPoints];
81
82 for(int i=0; i<this.nPoints; i++){
83 for(int j=0; j<mPoints; j++)yTempn[j]=y[i][j];
84 this.csn[i].resetData(x2,yTempn);
85 this.csn[i].calcDeriv();
86 }
87 }
88
89 // METHOD
90
91 // Returns an interpolated value of y for a value of x
92 // from a tabulated function y=f(x1,x2)
93 public double interpolate(double xx1, double xx2){
94
95 double[] yTempm = new double[this.nPoints];
96
97 for (int i=0;i<this.nPoints;i++){
98 yTempm[i]=this.csn[i].interpolate(xx2);
99 }
100 this.csm.resetData(x1,yTempm);
101 return this.csm.interpolate(xx1);
102 }
103}
104
Note: See TracBrowser for help on using the repository browser.