[cig-commits] r13167 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Oct 29 15:11:33 PDT 2008
Author: luis
Date: 2008-10-29 15:11:33 -0700 (Wed, 29 Oct 2008)
New Revision: 13167
Modified:
cs/cigma/trunk/src/py_Quadrature.cpp
cs/cigma/trunk/src/py_Quadrature.h
Log:
Construct a new pyQuadrature given a Quadrature
Modified: cs/cigma/trunk/src/py_Quadrature.cpp
===================================================================
--- cs/cigma/trunk/src/py_Quadrature.cpp 2008-10-29 22:11:31 UTC (rev 13166)
+++ cs/cigma/trunk/src/py_Quadrature.cpp 2008-10-29 22:11:33 UTC (rev 13167)
@@ -1,4 +1,5 @@
#include <iostream>
+#include <boost/shared_ptr.hpp>
#include "py_Quadrature.h"
using namespace cigma;
@@ -12,15 +13,20 @@
pyQuadrature::pyQuadrature(int npts, int ndim) : Quadrature(), na_points(0), na_weights(0)
{
+ this->npts = npts;
+ this->ndim = ndim;
+
std::vector<int> point_dims;
point_dims.push_back(npts);
point_dims.push_back(ndim);
+
na_points = numpy_util::makeArray(point_dims, PyArray_DOUBLE);
na_weights = numpy_util::makeArray(npts, PyArray_DOUBLE);
- this->npts = npts;
- this->ndim = ndim;
+
this->points = (double *)numpy_util::data(na_points);
this->weights = (double *)numpy_util::data(na_weights);
+
+ /* makeArray actually returns a zero'd out array...
for (int q = 0; q < npts; q++)
{
this->weights[q] = 0;
@@ -28,6 +34,31 @@
{
this->points[ndim*q + j] = 0;
}
+ } */
+}
+
+pyQuadrature::pyQuadrature(const Quadrature &Q) : Quadrature(), na_points(0), na_weights(0)
+{
+ this->npts = Q.n_points();
+ this->ndim = Q.n_dim();
+
+ std::vector<int> point_dims;
+ point_dims.push_back(npts);
+ point_dims.push_back(ndim);
+
+ na_points = numpy_util::makeArray(point_dims, PyArray_DOUBLE);
+ na_weights = numpy_util::makeArray(npts, PyArray_DOUBLE);
+
+ this->points = (double *)numpy_util::data(na_points);
+ this->weights = (double *)numpy_util::data(na_weights);
+
+ for (int q = 0; q < npts; q++)
+ {
+ this->weights[q] = Q.getWeight(q);
+ for (int j = 0; j < ndim; j++)
+ {
+ this->points[ndim*q + j] = Q.getPoint(q,j);
+ }
}
}
@@ -151,5 +182,7 @@
.add_property("points", &pq::getPoints, &pq::setPoints)
.add_property("weights", &pq::getWeights, &pq::setWeights)
;
+
+ register_ptr_to_python< boost::shared_ptr<pyQuadrature> >();
}
Modified: cs/cigma/trunk/src/py_Quadrature.h
===================================================================
--- cs/cigma/trunk/src/py_Quadrature.h 2008-10-29 22:11:31 UTC (rev 13166)
+++ cs/cigma/trunk/src/py_Quadrature.h 2008-10-29 22:11:33 UTC (rev 13167)
@@ -8,6 +8,7 @@
{
pyQuadrature();
pyQuadrature(int npts, int ndim);
+ pyQuadrature(const cigma::Quadrature& Q);
~pyQuadrature();
double getPoint(int q, int j) const;
More information about the CIG-COMMITS
mailing list