aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-08-28 11:07:02 +0200
committerAnton Khirnov <anton@khirnov.net>2016-08-28 11:14:49 +0200
commitd1cb9dbdea9d777833cd7f2148ea7ac5bcdb7d8b (patch)
tree5d3649d9da0799fe7860c5eb480dd9d5bce35094
parent4633e6db474e7825979bef26e68628d492a63eb1 (diff)
basis: add the basis of even cosines
-rw-r--r--basis.c30
-rw-r--r--basis.h1
2 files changed, 31 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;
diff --git a/basis.h b/basis.h
index 6b6f3c4..68c9597 100644
--- a/basis.h
+++ b/basis.h
@@ -26,6 +26,7 @@ enum BSEvalType {
enum BasisFamily {
BASIS_FAMILY_SB_EVEN,
+ BASIS_FAMILY_COS_EVEN,
};
typedef struct BasisSetContext BasisSetContext;