/*
* Copyright (c) 2004-2005, The Hong Kong University of Science and Technology (HKUST)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*   * Redistributions of source code must retain the above copyright notice,
*     this list of conditions,the authors and the following disclaimer.
*   * Redistributions in binary form must reproduce the above copyright notice,
*     this list of conditions,the authors and the following disclaimer in
*     the documentation and/or other materials provided with the distribution.
*   * Neither the name of the university nor the names of its
*     contributors may be used to endorse or promote products derived from
*     this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
 * SDGEN: a data generator for Bisque
 * @Author: Bingsheng He (saven@cs.ust.hk)
 * @Date:28/3/3005
 * @Version: 1.0
 * @Function: Interpolation.
 */

 import cc.kss.sci.interp.*;
 import cc.kss.sci.linalg.*;

 public class MyInterp{
 	/*double [] x0;
 	double [] y0;
 	double [] x;
 	double [] y;*/
 	SimpleVectorF x0;
 	SimpleVectorF y0;
 	double []y;

 	PolynomialInterpolatorF interp;

 	MyInterp(float []v_x0, float []v_y0)
 	{
 		x0=new SimpleVectorF(v_x0);
 		y0=new SimpleVectorF(v_y0);

 		interp=new PolynomialInterpolatorF(x0,y0,1);
 	}


 	void dumpValues(double start, double end, double interval)
 	{
 		int num=(int)((end-start)/interval);
 		y=new double[num+1];
 		int index=0;

 		try{
 		for(double i=start;i<end;i=i+interval)
 		{
 			y[index]=interp.interpolate((float)i);
 			//System.out.println(i+"-->"+y[index]);
 			index++;
 		}
 	}catch(Exception e)
 	{
 		System.out.println("in MyInterp, dumpValues: "+e);
 	}


 	}


 	public static void main(String []argv)
 	{
 		float v_x[]={1,2,3,4,5,6,7,8,9,10,100};
 		float v_y[]={1,2,3,4,5,5,4,3,2,1,2};
 		MyInterp my=new MyInterp(v_x,v_y);
 		/*for(int i=1;i<10;i++)
 			System.out.println(((double)i+0.5)+"-->"+my.getX((double)i+0.5));*/
 		my.dumpValues(1,100,0.5);

 	}

 }