@@ -11,7 +11,8 @@ void test_fp16( void );
1111void test_crc ( void );
1212void test_ltisys ( void );
1313void test_ffmath ( void );
14-
14+ void test_mat ( void );
15+ void test_interp1 ( void );
1516
1617void test_fis3 ( void )
1718{
@@ -304,6 +305,108 @@ void test_ffmath(void)
304305 cout << ffmath::getInf () << endl;
305306}
306307
308+ void test_mat ( void )
309+ {
310+ cout<<" MAT TEST" <<endl;
311+ mat<2 ,2 > x (
312+ 1 .0f , 2 .0f ,
313+ 3 .0f , 4 .0f
314+ );
315+ mat<2 ,1 > y (
316+ 1 .0f ,
317+ 3 .0f
318+ );
319+ mat<2 ,1 > z (
320+ 2 .0f ,
321+ 2 .0f
322+ );
323+
324+ mat<2 ,1 > result = 4.5 - z - 2 .0f *x*y - 3 ;
325+ mat<4 ,4 > I ( MAT_IDENTITY );
326+ x*=x;
327+ result.display ();
328+ x.display ();
329+ cout<< x (2 ) << endl;
330+ auto j = !y;
331+ j.display ();
332+ I.display ();
333+ auto ix = x.inv ();
334+ x.display ();
335+ ix.display ();
336+ (x*ix).display ();
337+
338+ }
339+
340+ void test_interp1 ( void )
341+ {
342+ real_t tx[] = { 1 .0f , 2 .0f , 3 .0f , 4 .0f };
343+ real_t ty[] = { 5 .0f , 9 .0f , 12 .0f , 15 .0f };
344+ interp1 interpolation ( tx, ty );
345+
346+ cout << " linear" << endl;
347+ interpolation.setMethod ( INTERP1_LINEAR );
348+ cout << interpolation.get ( 2.5 ) << endl;
349+ cout << interpolation.get ( 3.1 ) << endl;
350+ cout << interpolation.get ( 0.5 ) << endl;
351+ cout << interpolation.get ( 5.0 ) << endl;
352+
353+ cout << " sine" << endl;
354+ interpolation.setMethod ( INTERP1_SINE );
355+ cout << interpolation.get ( 2.5 ) << endl;
356+ cout << interpolation.get ( 3.1 ) << endl;
357+ cout << interpolation.get ( 0.5 ) << endl;
358+ cout << interpolation.get ( 5.0 ) << endl;
359+
360+ cout << " cubic" << endl;
361+ interpolation.setMethod ( INTERP1_CUBIC );
362+ cout << interpolation.get ( 2.5 ) << endl;
363+ cout << interpolation.get ( 3.1 ) << endl;
364+ cout << interpolation.get ( 0.5 ) << endl;
365+ cout << interpolation.get ( 5.0 ) << endl;
366+
367+ cout << " hermite" << endl;
368+ interpolation.setMethod ( INTERP1_HERMITE );
369+ cout << interpolation.get ( 2.5 ) << endl;
370+ cout << interpolation.get ( 3.1 ) << endl;
371+ cout << interpolation.get ( 0.5 ) << endl;
372+ cout << interpolation.get ( 5.0 ) << endl;
373+
374+ cout << " nearest" << endl;
375+ interpolation.setMethod ( INTERP1_NEAREST);
376+ cout << interpolation.get ( 2.5 ) << endl;
377+ cout << interpolation.get ( 3.1 ) << endl;
378+ cout << interpolation.get ( 0.5 ) << endl;
379+ cout << interpolation.get ( 5.0 ) << endl;
380+
381+ cout << " next" << endl;
382+ interpolation.setMethod ( INTERP1_NEXT);
383+ cout << interpolation.get ( 2.5 ) << endl;
384+ cout << interpolation.get ( 3.1 ) << endl;
385+ cout << interpolation.get ( 0.5 ) << endl;
386+ cout << interpolation.get ( 5.0 ) << endl;
387+
388+ cout << " previous" << endl;
389+ interpolation.setMethod ( INTERP1_PREVIOUS);
390+ cout << interpolation.get ( 2.5 ) << endl;
391+ cout << interpolation.get ( 3.1 ) << endl;
392+ cout << interpolation.get ( 0.5 ) << endl;
393+ cout << interpolation.get ( 5.0 ) << endl;
394+
395+ cout << " spline" << endl;
396+ interpolation.setMethod ( INTERP1_SPLINE);
397+ cout << interpolation.get ( 2.5 ) << endl;
398+ cout << interpolation.get ( 3.1 ) << endl;
399+ cout << interpolation.get ( 0.5 ) << endl;
400+ cout << interpolation.get ( 5.0 ) << endl;
401+
402+ cout << " cspline" << endl;
403+ interpolation.setMethod ( INTERP1_CONSTRAINED_SPLINE);
404+ cout << interpolation.get ( 2.5 ) << endl;
405+ cout << interpolation.get ( 3.1 ) << endl;
406+ cout << interpolation.get ( 0.5 ) << endl;
407+ cout << interpolation.get ( 5.0 ) << endl;
408+ }
409+
307410int main ()
308411{
309412 test_crc ();
@@ -314,5 +417,7 @@ int main()
314417 test_fis2 ();
315418 test_fis3 ();
316419 test_ffmath ();
420+ test_mat ();
421+ test_interp1 ();
317422 return 0 ;
318423}
0 commit comments