Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:06

0001 #pragma once
0002 
0003 #include "NPFold.h"
0004 #include "QProp.hh"
0005 
0006 template <typename T>
0007 struct QPropTest
0008 {
0009     static constexpr const char* RELDIR = sizeof(T) == 8 ? "double" : "float" ; 
0010     const QProp<T>* qprop ; 
0011     int nx ; 
0012     const NP* a ; 
0013     const NP* x ; 
0014     NP* y ; 
0015 
0016     QPropTest( const NP* propcom, T x0, T x1, int nx_ ); 
0017     void lookup(); 
0018     NPFold* serialize() const ; 
0019     void save() const ; 
0020 }; 
0021 
0022 template <typename T>
0023 inline QPropTest<T>::QPropTest( const NP* propcom, T x0, T x1, int nx_ )
0024     :
0025     qprop(new QProp<T>(propcom)),
0026     nx(nx_),
0027     a(qprop->a), 
0028     x(NP::Linspace<T>( x0, x1, nx )),
0029     y(NP::Make<T>(qprop->ni, nx ))
0030 {
0031 }
0032 
0033 
0034 /**
0035 QPropTest::lookup
0036 -------------------
0037 
0038 nx lookups in x0->x1 inclusive for each property yielding nx*qp.ni values.
0039 
0040 1. create *x* domain array of shape (nx,) with values in range x0 to x1 
0041 2. create *y* lookup array of shape (qp.ni, nx ) 
0042 3. invoke QProp::lookup collecting *y* lookup values from kernel call 
0043 4. save prop, domain and lookup into fold/reldir
0044 
0045 **/
0046 
0047 template <typename T>
0048 inline void QPropTest<T>::lookup()
0049 {
0050     qprop->lookup(y->values<T>(), x->cvalues<T>(), qprop->ni, nx );
0051 }
0052 
0053 template <typename T>
0054 inline NPFold* QPropTest<T>::serialize() const
0055 {
0056     NPFold* f = new NPFold ; 
0057     f->add("prop", a );  
0058     f->add("domain", x );  
0059     f->add("lookup", y );  
0060     return f ; 
0061 }
0062 
0063 template <typename T>
0064 inline void QPropTest<T>::save() const
0065 {
0066     NPFold* f = serialize(); 
0067     f->save("$TMP/QPropTest", RELDIR ) ; 
0068 }
0069 
0070 
0071