Skip to content

Commit

Permalink
specialize addmul, submul for nfloat
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed May 17, 2024
1 parent 8611346 commit 9840dfe
Show file tree
Hide file tree
Showing 8 changed files with 496 additions and 7 deletions.
4 changes: 4 additions & 0 deletions doc/source/nfloat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ These methods are interchangeable with their ``gr`` counterparts.
int nfloat_add(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)
int nfloat_sub(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)
int nfloat_mul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)
int nfloat_submul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)
int nfloat_addmul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx)

.. function:: int nfloat_mul_2exp_si(nfloat_ptr res, nfloat_srcptr x, slong y, gr_ctx_t ctx)

Expand Down Expand Up @@ -303,6 +305,8 @@ code for reduced overhead.
int _nfloat_vec_sub(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx)
int _nfloat_vec_mul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx)
int _nfloat_vec_mul_scalar(nfloat_ptr res, nfloat_srcptr x, slong len, nfloat_srcptr y, gr_ctx_t ctx)
int _nfloat_vec_addmul_scalar(nfloat_ptr res, nfloat_srcptr x, slong len, nfloat_srcptr y, gr_ctx_t ctx)
int _nfloat_vec_submul_scalar(nfloat_ptr res, nfloat_srcptr x, slong len, nfloat_srcptr y, gr_ctx_t ctx)

.. function:: int _nfloat_vec_dot(nfloat_ptr res, nfloat_srcptr initial, int subtract, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx)
int _nfloat_vec_dot_rev(nfloat_ptr res, nfloat_srcptr initial, int subtract, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx)
Expand Down
4 changes: 4 additions & 0 deletions src/nfloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ int _nfloat_sub_n(nfloat_ptr res, nn_srcptr xd, slong xexp, int xsgnbit, nn_srcp
int nfloat_add(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx);
int nfloat_sub(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx);
int nfloat_mul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx);
int nfloat_addmul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx);
int nfloat_submul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, gr_ctx_t ctx);

int nfloat_mul_2exp_si(nfloat_ptr res, nfloat_srcptr x, slong y, gr_ctx_t ctx);

Expand Down Expand Up @@ -344,6 +346,8 @@ int _nfloat_vec_add(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, slong len,
int _nfloat_vec_sub(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx);
int _nfloat_vec_mul(nfloat_ptr res, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx);
int _nfloat_vec_mul_scalar(nfloat_ptr res, nfloat_srcptr x, slong len, nfloat_srcptr y, gr_ctx_t ctx);
int _nfloat_vec_addmul_scalar(nfloat_ptr res, nfloat_srcptr x, slong len, nfloat_srcptr y, gr_ctx_t ctx);
int _nfloat_vec_submul_scalar(nfloat_ptr res, nfloat_srcptr x, slong len, nfloat_srcptr y, gr_ctx_t ctx);

int _nfloat_vec_dot(nfloat_ptr res, nfloat_srcptr initial, int subtract, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx);
int _nfloat_vec_dot_rev(nfloat_ptr res, nfloat_srcptr initial, int subtract, nfloat_srcptr x, nfloat_srcptr y, slong len, gr_ctx_t ctx);
Expand Down
4 changes: 4 additions & 0 deletions src/nfloat/ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ gr_method_tab_input _nfloat_methods_input[] =
{GR_METHOD_MUL_SI, (gr_funcptr) nfloat_mul_si},
{GR_METHOD_MUL_FMPZ, (gr_funcptr) nfloat_mul_fmpz},
{GR_METHOD_MUL_TWO, (gr_funcptr) nfloat_mul_two},
*/
{GR_METHOD_ADDMUL, (gr_funcptr) nfloat_addmul},
{GR_METHOD_SUBMUL, (gr_funcptr) nfloat_submul},
/*
{GR_METHOD_SQR, (gr_funcptr) nfloat_sqr},
*/
{GR_METHOD_DIV, (gr_funcptr) nfloat_div},
Expand Down Expand Up @@ -163,6 +165,8 @@ gr_method_tab_input _nfloat_methods_input[] =
{GR_METHOD_VEC_SUB, (gr_funcptr) _nfloat_vec_sub},
{GR_METHOD_VEC_MUL, (gr_funcptr) _nfloat_vec_mul},
{GR_METHOD_VEC_MUL_SCALAR, (gr_funcptr) _nfloat_vec_mul_scalar},
{GR_METHOD_VEC_ADDMUL_SCALAR, (gr_funcptr) _nfloat_vec_addmul_scalar},
{GR_METHOD_VEC_SUBMUL_SCALAR, (gr_funcptr) _nfloat_vec_submul_scalar},
{GR_METHOD_VEC_DOT, (gr_funcptr) _nfloat_vec_dot},
{GR_METHOD_VEC_DOT_REV, (gr_funcptr) _nfloat_vec_dot_rev},
/*
Expand Down
Loading

0 comments on commit 9840dfe

Please sign in to comment.