[cig-commits] r8942 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Dec 19 12:06:08 PST 2007
Author: luis
Date: 2007-12-19 12:06:07 -0800 (Wed, 19 Dec 2007)
New Revision: 8942
Added:
cs/benchmark/cigma/trunk/src/Points.cpp
cs/benchmark/cigma/trunk/src/Points.h
Log:
Class for storing geometric points
Added: cs/benchmark/cigma/trunk/src/Points.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Points.cpp 2007-12-19 20:06:00 UTC (rev 8941)
+++ cs/benchmark/cigma/trunk/src/Points.cpp 2007-12-19 20:06:07 UTC (rev 8942)
@@ -0,0 +1,26 @@
+#include "Points.h"
+
+// ---------------------------------------------------------------------------
+
+cigma::Points::Points()
+{
+ num = 0;
+ dim = 0;
+ data = 0;
+}
+
+cigma::Points::~Points()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+
+void cigma::Points::set_data(double *data, int num, int dim)
+{
+ this->data = data;
+ this->num = num;
+ this->dim = dim;
+}
+
+// ---------------------------------------------------------------------------
Added: cs/benchmark/cigma/trunk/src/Points.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Points.h 2007-12-19 20:06:00 UTC (rev 8941)
+++ cs/benchmark/cigma/trunk/src/Points.h 2007-12-19 20:06:07 UTC (rev 8942)
@@ -0,0 +1,74 @@
+#ifndef __POINTS_H__
+#define __POINTS_H__
+
+#include <cassert>
+
+namespace cigma
+{
+ class Points;
+}
+
+/**
+ * @brief Array object representing a set of points as a contiguous
+ * memory block (row major storage).
+ *
+ */
+class cigma::Points
+{
+public:
+ Points();
+ ~Points();
+
+public:
+ void set_data(double *data, int num, int dim);
+
+public:
+ double operator()(int i, int j);
+ double *operator[](int i);
+
+public:
+ int n_points() const;
+ int n_dim() const;
+ int index(int i, int j) const;
+
+public:
+ int num;
+ int dim;
+ double *data;
+};
+
+// ---------------------------------------------------------------------------
+
+inline double cigma::Points::operator()(int i, int j)
+{
+ //assert(0 <= i); assert(i < num);
+ //assert(0 <= j); assert(j < dim);
+ return data[index(i,j)];
+}
+
+inline double *cigma::Points::operator[](int i)
+{
+ //assert(0 <= i); assert(i < num);
+ return &data[dim*i];
+}
+
+inline int cigma::Points::n_points() const
+{
+ return num;
+}
+
+inline int cigma::Points::n_dim() const
+{
+ return dim;
+}
+
+inline int cigma::Points::index(int i, int j) const
+{
+ //assert(0 <= i); assert(i < num);
+ //assert(0 <= j); assert(j < dim);
+ return dim*i + j;
+}
+
+// ---------------------------------------------------------------------------
+
+#endif
More information about the cig-commits
mailing list