[cig-commits] r13626 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Tue Dec 9 18:16:26 PST 2008


Author: luis
Date: 2008-12-09 18:16:26 -0800 (Tue, 09 Dec 2008)
New Revision: 13626

Modified:
   cs/cigma/trunk/src/fn_explicit.cpp
   cs/cigma/trunk/src/fn_explicit.h
Log:
Simple pointwise function

Modified: cs/cigma/trunk/src/fn_explicit.cpp
===================================================================
--- cs/cigma/trunk/src/fn_explicit.cpp	2008-12-10 02:16:25 UTC (rev 13625)
+++ cs/cigma/trunk/src/fn_explicit.cpp	2008-12-10 02:16:26 UTC (rev 13626)
@@ -11,5 +11,36 @@
 
 bool ExplicitFn::eval(double *point, double *value)
 {
+    // XXX: find value of closest point?
     return false;
 }
+
+bool ExplicitFn::getPoint(int i, double *point) const
+{
+    if ((i < 0) || (i >= points.n_points()))
+    {
+        return false;
+    }
+
+    for (int j = 0; j < n_dim(); j++)
+    {
+        point[j] = points(i,j);
+    }
+
+    return true;
+}
+
+bool ExplicitFn::getValue(int i, double *value) const
+{
+    if ((i < 0) || (i >= values.n_points()))
+    {
+        return false;
+    }
+
+    for (int j = 0; j < n_rank(); j++)
+    {
+        value[j] = values(i,j);
+    }
+
+    return true;
+}

Modified: cs/cigma/trunk/src/fn_explicit.h
===================================================================
--- cs/cigma/trunk/src/fn_explicit.h	2008-12-10 02:16:25 UTC (rev 13625)
+++ cs/cigma/trunk/src/fn_explicit.h	2008-12-10 02:16:26 UTC (rev 13626)
@@ -19,10 +19,30 @@
     int n_rank() const;
     bool eval(double *point, double *value);
 
+    Function::type getType() const;
+
+    bool getPoint(int i, double *point) const;
+    bool getValue(int i, double *value) const;
+
 public:
     cigma::array<double> points;
     cigma::array<double> values;
 };
 
+inline int cigma::ExplicitFn::n_dim() const
+{
+    return points.n_dim();
+}
 
+inline int cigma::ExplicitFn::n_rank() const
+{
+    return values.n_dim();
+}
+
+inline cigma::Function::type cigma::ExplicitFn::getType() const
+{
+    return cigma::Function::POINTWISE_FN;
+}
+
+
 #endif



More information about the CIG-COMMITS mailing list