X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftags%2FETL_%40VERSION_MAJ%40_%40VERSION_MIN%40_%40VERSION_REV%40%2Ftest%2Fspline.cpp;fp=ETL%2Ftags%2FETL_%40VERSION_MAJ%40_%40VERSION_MIN%40_%40VERSION_REV%40%2Ftest%2Fspline.cpp;h=eaae237dfa3772a79eb4fe33e2c38387d1cc4606;hb=609ffb6c7ad2996e4dde68b1066a27e80ed8a153;hp=0000000000000000000000000000000000000000;hpb=2431de3e401e81fb920d57b4c278bd2b156c277e;p=synfig.git diff --git a/ETL/tags/ETL_@VERSION_MAJ@_@VERSION_MIN@_@VERSION_REV@/test/spline.cpp b/ETL/tags/ETL_@VERSION_MAJ@_@VERSION_MIN@_@VERSION_REV@/test/spline.cpp new file mode 100644 index 0000000..eaae237 --- /dev/null +++ b/ETL/tags/ETL_@VERSION_MAJ@_@VERSION_MIN@_@VERSION_REV@/test/spline.cpp @@ -0,0 +1,99 @@ +/*! ======================================================================== +** Extended Template and Library Test Suite +** Spline Curve Test +** $Id$ +** +** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** === N O T E S =========================================================== +** +** ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#include +#include +#include +#include +#include + +/* === M A C R O S ========================================================= */ + +using namespace etl; + +/* === C L A S S E S ======================================================= */ + + +/* === P R O C E D U R E S ================================================= */ + +int bspline_basic_test(void) +{ + int ret=0; + float f; + + bspline BSpline; + etl::clock timer; + double t; + + *BSpline.cpoints().insert(BSpline.cpoints().end())=0; + *BSpline.cpoints().insert(BSpline.cpoints().end())=-1; + *BSpline.cpoints().insert(BSpline.cpoints().end())=0; + *BSpline.cpoints().insert(BSpline.cpoints().end())=1; + *BSpline.cpoints().insert(BSpline.cpoints().end())=0; + + BSpline.set_m(4); + BSpline.reset_knots(); + + integral > inte(BSpline); + + + /* + for(f=0.0;f<1.001;f+=0.05) + fprintf(stderr,"BSpline(%f)= %f\n",f,BSpline(f)); + */ + + fprintf(stderr,"integral of BSpline() on [0,1] = %f\n",inte(0,1.0)); + + + for(f=0.0f,timer.reset();f<1.001f;f+=0.000005f) + { + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + t+=BSpline(f)+BSpline(f+0.1f); + } + t=timer(); + + fprintf(stderr,"BSpline time=%f milliseconds\n",t*1000); + return ret; +} + +/* === E N T R Y P O I N T ================================================= */ + +int main() +{ + int error=0; + + error+=bspline_basic_test(); + + return error; +} +