void TestCompositionMultiplicationFonction() { boost::function<double(double)> f_boost = boost::bind(f123, _1); boost::function<double(double)> g_boost = boost::bind(g123, _1); RR_Function_ComposeByProduct f_mult(f_boost, g_boost) ; std::cout << "f_mult(1) = f(1)*g(1) = " << f_mult(1) << " vs 1" << std::endl ; std::cout << "f_mult(2) = f(2)*g(2) = " << f_mult(2) << " vs 4" << std::endl ; }
f_besj1() /* j1(a) = sin(a)/(a**2) - cos(a)/a */ { struct value a; a = top_of_stack; f_sin(); push(&a); push(&a); f_mult(); f_div(); push(&a); f_cos(); push(&a); f_div(); f_minus(); }
int main(int argc, char**argv){ fun_t *f; f = f_mult(f_window(f_cu(0,SEC),f_cu(3,SEC)), f_sin(f_c(1),f_cu(50,HZ),f_c(0)) ); f = f_add(f, f_mult(f_window(f_cu(3,SEC),f_cu(6,SEC)), f_tri(f_c(1),f_cu(50,HZ),f_c(0)) )); f = f_add(f, f_mult(f_window(f_cu(6,SEC),f_cu(9,SEC)), f_square(f_c(1),f_cu(50,HZ),f_c(0),f_c(0.5)) )); set_bpm(f_ramp(f_cu(2,SEC),f_cu(8,SEC),f_c(60),f_c(70))); set_period(f_c(4)); /* fun_print(f); */ f = s_down_sample(f_c(10),f); fun_record_16b(f,0,SAMPLING_RATE*10,2,buffer); audio_write_stereo_16b(buffer,SAMPLING_RATE*2*2*10,"test.wav"); return 0; }
f_besy1() /* y1(a) = -cos(a)/(a**2) - sin(a)/a */ { struct value a; a = top_of_stack; f_cos(); push(&a); push(&a); f_mult(); f_div(); push(&a); f_sin(); push(&a); f_div(); f_plus(); f_uminus(); }
/* evaluate an expression term, eval_err will indicate it any expression evaluation occurs */ static struct eval_value_t /* value to expression term */ term(struct eval_state_t *es) /* expression evaluator */ { enum eval_token_t tok; struct eval_value_t val, val1; val = factor(es); if (eval_error) return err_value; tok = peek_next_token(es); switch (tok) { case tok_mult: (void)get_next_token(es); val = f_mult(val, term(es)); if (eval_error) return err_value; break; case tok_div: (void)get_next_token(es); val1 = term(es); if (eval_error) return err_value; if (f_eq_zero(val1)) { eval_error = ERR_DIV0; return err_value; } val = f_div(val, val1); break; default:; } return val; }
void s_gridNDIM::mult(double s) { FortranRegion Fthis(this->region()); f_mult(FORTRAN_DATA(*this), FORTRAN_REGIONNDIM(Fthis), &s); };