[cig-commits] r11412 - in cs/benchmark/cigma/trunk/src: . tests
luis at geodynamics.org
luis at geodynamics.org
Wed Mar 12 11:03:00 PDT 2008
Author: luis
Date: 2008-03-12 11:03:00 -0700 (Wed, 12 Mar 2008)
New Revision: 11412
Added:
cs/benchmark/cigma/trunk/src/ZeroFunction.cpp
cs/benchmark/cigma/trunk/src/ZeroFunction.h
cs/benchmark/cigma/trunk/src/tests/TestZeroFunction.cpp
Modified:
cs/benchmark/cigma/trunk/src/Makefile.am
cs/benchmark/cigma/trunk/src/tests/Makefile
Log:
Added class ZeroFunction
Modified: cs/benchmark/cigma/trunk/src/Makefile.am
===================================================================
--- cs/benchmark/cigma/trunk/src/Makefile.am 2008-03-12 18:02:58 UTC (rev 11411)
+++ cs/benchmark/cigma/trunk/src/Makefile.am 2008-03-12 18:03:00 UTC (rev 11412)
@@ -147,5 +147,7 @@
VtkWriter.cpp \
VtkWriter.h \
Writer.cpp \
- Writer.h
+ Writer.h \
+ ZeroFunction.cpp \
+ ZeroFunction.h
Added: cs/benchmark/cigma/trunk/src/ZeroFunction.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/ZeroFunction.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/ZeroFunction.cpp 2008-03-12 18:03:00 UTC (rev 11412)
@@ -0,0 +1,12 @@
+#include "ZeroFunction.h"
+
+using namespace cigma;
+
+void ZeroFunction::eval(double *x, double *y)
+{
+ for (int i = 0; i < rank; i++)
+ {
+ y[i] = 0.0;
+ }
+}
+
Added: cs/benchmark/cigma/trunk/src/ZeroFunction.h
===================================================================
--- cs/benchmark/cigma/trunk/src/ZeroFunction.h (rev 0)
+++ cs/benchmark/cigma/trunk/src/ZeroFunction.h 2008-03-12 18:03:00 UTC (rev 11412)
@@ -0,0 +1,32 @@
+#ifndef __ZERO_FUNCTION_H__
+#define __ZERO_FUNCTION_H__
+
+#include "Field.h"
+
+namespace cigma {
+ class ZeroFunction;
+}
+
+class cigma::ZeroFunction : Field
+{
+public:
+ void eval(double *point, double *value);
+
+public:
+ int n_dim() { return dim; }
+ int n_rank() { return rank; }
+
+public:
+ void set_shape(int dim, int rank)
+ {
+ this->dim = dim;
+ this->rank = rank;
+ }
+
+public:
+ int dim;
+ int rank;
+};
+
+#endif
+
Modified: cs/benchmark/cigma/trunk/src/tests/Makefile
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/Makefile 2008-03-12 18:02:58 UTC (rev 11411)
+++ cs/benchmark/cigma/trunk/src/tests/Makefile 2008-03-12 18:03:00 UTC (rev 11412)
@@ -34,6 +34,7 @@
TestAnn.o \
TestAnnLocator.o \
TestHdfReader.o \
+ TestZeroFunction.o \
TESTS = $(TESTOBJS:.o=.out)
Added: cs/benchmark/cigma/trunk/src/tests/TestZeroFunction.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestZeroFunction.cpp (rev 0)
+++ cs/benchmark/cigma/trunk/src/tests/TestZeroFunction.cpp 2008-03-12 18:03:00 UTC (rev 11412)
@@ -0,0 +1,33 @@
+#include <iostream>
+#include "../ZeroFunction.h"
+
+using namespace std;
+using namespace cigma;
+
+int main()
+{
+ ZeroFunction *F = new ZeroFunction();
+
+ const int n = 10;
+ double x[n], y[n];
+
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ x[i] = i / (1.0 * n);
+ }
+
+ F->set_shape(1,1);
+
+ for (i = 0; i < n; i++)
+ {
+ F->eval(&x[i], &y[i]);
+ }
+
+ for (i = 0; i < n; i++)
+ {
+ cout << "F(" << x[i] << ") = " << y[i] << endl;
+ }
+
+ return 0;
+}
More information about the cig-commits
mailing list