aboutsummaryrefslogtreecommitdiff
path: root/basis.c
diff options
context:
space:
mode:
Diffstat (limited to 'basis.c')
-rw-r--r--basis.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/basis.c b/basis.c
index face638..bb3a8e9 100644
--- a/basis.c
+++ b/basis.c
@@ -101,6 +101,33 @@ static const BasisSet sb_even_basis = {
.colloc_point = sb_even_colloc_point,
};
+static double cos_even_eval(const BasisSetContext *s, double coord, int idx)
+{
+ return cos(2 * idx * coord);
+}
+
+static double cos_even_eval_diff1(const BasisSetContext *s, double coord, int idx)
+{
+ return -2 * idx * sin(2 * idx * coord);
+}
+
+static double cos_even_eval_diff2(const BasisSetContext *s, double coord, int idx)
+{
+ return -4 * SQR(idx) * cos(2 * idx * coord);
+}
+
+static double cos_even_colloc_point(const BasisSetContext *s, int order, int idx)
+{
+ return M_PI * idx / (2 * order);
+}
+
+static const BasisSet cos_even_basis = {
+ .eval = cos_even_eval,
+ .eval_diff1 = cos_even_eval_diff1,
+ .eval_diff2 = cos_even_eval_diff2,
+ .colloc_point = cos_even_colloc_point,
+};
+
double bdi_basis_eval(BasisSetContext *s, enum BSEvalType type, double coord, int order)
{
double (*eval)(const BasisSetContext *s, double coord, int order);
@@ -138,6 +165,9 @@ BasisSetContext *bdi_basis_init(enum BasisFamily family, double sf)
s->bs = &sb_even_basis;
s->sf = sf;
break;
+ case BASIS_FAMILY_COS_EVEN:
+ s->bs = &cos_even_basis;
+ break;
default:
free(s);
return NULL;