#!/usr/bin/python

#import FuncComb
import Manyo
import BuildInFunc

expr=""
for i in range(5):
    expr = expr + " g"
print expr

#        0    1    2    3    4    5    6    7    8    9   10   11   12   13   14
param=[1.0, 0.0, 1.0, 2.0, 0.0, 2.0, 3.0, 0.0, 3.0, 4.0, 0.0, 4.0, 5.0, 0.0, 5.0]
error=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
pv=Manyo.DoubleVector()
ev=Manyo.DoubleVector()

#parser=FuncComb.FuncParser(expr);
#funcList=parser.parse()
#funcList.clear()

func=BuildInFunc.FuncComb()
func.dump()
func=BuildInFunc.FuncComb(expr)
func.dump()
func=BuildInFunc.FuncComb(expr, param)
func.dump()
func=BuildInFunc.FuncComb(expr, param, error)
func.dump()

xmin=-5.0
xmax= 5.0
div=100
#delta=(xmax - xmin)/div
delta=(xmax - xmin) / div
print "xmin=", xmin, " xmax=", xmax, " div=", div, " delta=", delta
for i in range(div+1):
    x=xmin+delta*i
    print i, x, func.eval(x), func.der1st(x), func.der2nd(x), func.evalError(x)
    for j in range(5):
        print i, j, x, func.evalComponent(x, j), func.der1stComponent(x, j), func.der2ndComponent(x, j), func.evalErrorComponent(x, j)


#x=[0.0, 0.1, 0.2, 0.3]
x=Manyo.DoubleVector()
x.push_back(0.0)
x.push_back(0.1)
x.push_back(0.3)
x.push_back(0.4)

values=func.eval(x)
print values.size()
for i in range( values.size() ):
    print i, x(i), values(i)
