// Simple filter example: Uses static allocation void simple_filter(length_type const N) { // Create an object given a fixed input signal length, known // at initialization time. May be allocated as a static or // global and persist throughout the lifetime of the program. Filter filter(N); Vector<cscalar_f> in(N, cscalar_f(1.f)); Vector<cscalar_f> k(N, cscalar_f(1.f)); Vector<cscalar_f> out(N); filter(in, k, out); }
// Resizable filter example: Uses dynamic allocation void resizable_filter(length_type const N) { // Create an object and defer allocation of the wrapped object // until reconfigure() is called, usually at a time after the system // is up and running and the size information has been obtained // via some sort of I/O (a file is read, or a message is received). Dynamic_filter filter; filter.reconfigure(N); Vector<cscalar_f> in(N, cscalar_f(1.f)); Vector<cscalar_f> k(N, cscalar_f(1.f)); Vector<cscalar_f> out(N); filter(in, k, out); // Change the input signal length and only operate on the first // half of the data, just to demonstrate how this is done. filter.reconfigure(N/2); Domain<1> n2(N/2); filter(in(n2), k(n2), out(n2)); }
void test_meansqval() { using vsip::Vector; using vsip::cscalar_f; using vsip::scalar_f; using vsip::meansqval; // Specification appears to be incorrect. Vector<cscalar_f> vec (2, cscalar_f (1.0, 0.0)); vec.put(0, cscalar_f(1.f, 0.f)); vec.put(1, cscalar_f(1.f, 0.f)); insist(equal(meansqval(vec), scalar_f(1.0))); vec.put(0, cscalar_f(0.f, 1.f)); vec.put(1, cscalar_f(0.f, 1.f)); insist(equal(meansqval(vec), scalar_f(1.0))); vec.put(0, cscalar_f(1.f, 0.f)); vec.put(1, cscalar_f(0.f, 2.f)); insist(equal(meansqval(vec), scalar_f(2.5))); }