Skip to content

Commit

Permalink
trunk: Reformatting. [all]
Browse files Browse the repository at this point in the history
git-svn-id: https://ipvs.informatik.uni-stuttgart.de/SGpp/repos/trunk@5515 4eea3252-f0fb-4393-894d-40516dce545b
  • Loading branch information
valentjn committed Feb 8, 2016
1 parent 3eb3dc8 commit 018c341
Show file tree
Hide file tree
Showing 1,659 changed files with 184,831 additions and 169,120 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ if env['PYDOC'] and env['SG_PYTHON']:

doxygen = doxy_env.Command(os.path.join(module, 'doc/xml/index.xml'), '', 'doxygen ' + os.path.join(module, 'Doxyfile'))

doxy2swig_command = "python pysgpp/doxy2swig.py -o -c " + ('' if env['VERBOSE'] else '-q') + " $SOURCE $TARGET"
doxy2swig_command = "python pysgpp/doxy2swig.py -o -c -q $SOURCE $TARGET"
doxy2swig = doxy_env.Command(os.path.join('pysgpp', module + '_doc.i'), doxygen, doxy2swig_command)

for root, dirs, files in os.walk(os.path.join(module, 'src')):
Expand Down
17 changes: 11 additions & 6 deletions base/examples/JSONTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,28 @@ int main(int argc, char** argv) {
try {
json::JSON configuration;

configuration.addDictAttr("parent").addTextAttr("t1", "v1").addTextAttr("t2", "v2").addListAttr("list1").addTextValue(
"tv1").addIdValue(96.0).addTextValue("tv2");
configuration.addDictAttr("parent").addTextAttr("t1", "v1").addTextAttr("t2",
"v2").addListAttr("list1").addTextValue(
"tv1").addIdValue(96.0).addTextValue("tv2");
configuration.addTextAttr("textAttr1", "text1").addIDAttr("numVal1", 36.0);

std::cout << "value: " << configuration["parent"]["list1"][1].get() << std::endl;
std::cout << "value: " << configuration["parent"]["list1"][1].get() <<
std::endl;

configuration["parent"]["list1"][1].setDouble(7);

std::cout << "value: " << configuration["parent"]["list1"][1].get() << std::endl;
std::cout << "value: " << configuration["parent"]["list1"][1].get() <<
std::endl;

std::cout << "value: " << configuration["parent"]["list1"][1].getDouble() << std::endl;
std::cout << "value: " << configuration["parent"]["list1"][1].getDouble() <<
std::endl;

configuration["numVal1"].erase();

std::unique_ptr<json::Node> parentNode = configuration["parent"].erase();

configuration.addDictAttr("parentparent").addAttribute("parent", std::move(parentNode));
configuration.addDictAttr("parentparent").addAttribute("parent",
std::move(parentNode));

configuration.serialize("write.json");

Expand Down
3 changes: 2 additions & 1 deletion base/examples/platformConfigurationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

int main(int argc, char** argv) {

std::shared_ptr<SGPP::base::OCLOperationConfiguration> configuration = std::make_shared<SGPP::base::OCLOperationConfiguration>("detectPlatform.cfg");
std::shared_ptr<SGPP::base::OCLOperationConfiguration> configuration =
std::make_shared<SGPP::base::OCLOperationConfiguration>("detectPlatform.cfg");
(*configuration).replaceIDAttr("VERBOSE", true);

SGPP::base::OCLManagerMultiPlatform manager(configuration);
Expand Down
12 changes: 8 additions & 4 deletions base/examples/predictive_refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ SGPP::float_t f(SGPP::float_t x0, SGPP::float_t x1) {
return sin(x0 * M_PI);
}

DataVector& calculateError(const DataMatrix& dataSet, Grid& grid, const DataVector& alpha, DataVector& error) {
DataVector& calculateError(const DataMatrix& dataSet, Grid& grid,
const DataVector& alpha, DataVector& error) {
cout << "calculating error" << endl;

//traverse dataSet
Expand All @@ -37,7 +38,8 @@ DataVector& calculateError(const DataMatrix& dataSet, Grid& grid, const DataVect

for (unsigned int i = 0; i < dataSet.getNrows(); i++) {
dataSet.getRow(i, vec);
error[i] = pow(f(dataSet.get(i, 0), dataSet.get(i, 1)) - opEval->eval(alpha, vec), 2);
error[i] = pow(f(dataSet.get(i, 0), dataSet.get(i, 1)) - opEval->eval(alpha,
vec), 2);
}

return error;
Expand Down Expand Up @@ -90,7 +92,8 @@ int main() {
}

// hierarchize
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(alpha);
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(
alpha);

// calculate squared offset
DataVector errorVector(dataSet.getNrows());
Expand All @@ -105,7 +108,8 @@ int main() {
PredictiveRefinementIndicator indicator(grid, &dataSet, &errorVector, 1);
decorator.free_refine(hashGridStorage, &indicator);

cout << "Refinement step " << step + 1 << ", new grid size: " << hashGridStorage->size() << endl;
cout << "Refinement step " << step + 1 << ", new grid size: " <<
hashGridStorage->size() << endl;

// plot grid

Expand Down
3 changes: 2 additions & 1 deletion base/examples/quadrature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ int main() {
alpha[i] = f(2, p, NULL);
}

SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(alpha);
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(
alpha);

// direct quadrature
OperationQuadrature* opQ = SGPP::op_factory::createOperationQuadrature(*grid);
Expand Down
6 changes: 4 additions & 2 deletions base/examples/refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ int main() {
}

// hierarchize
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(alpha);
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(
alpha);

// refine a single grid point each time
gridGen->refine(new SurplusRefinementFunctor(&alpha, 1));
cout << "refinement step " << step + 1 << ", new grid size: " << alpha.getSize() << endl;
cout << "refinement step " << step + 1 << ", new grid size: " << alpha.getSize()
<< endl;

// extend alpha vector (new entries uninitialized)
alpha.resize(gridStorage->size());
Expand Down
3 changes: 2 additions & 1 deletion base/examples/tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ int main() {
cout << "alpha before hierarchization: " << alpha.toString() << endl;

// hierarchize
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(alpha);
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(
alpha);
cout << "alpha after hierarchization: " << alpha.toString() << endl;

// evaluate
Expand Down
214 changes: 110 additions & 104 deletions base/src/sgpp/base/algorithm/AlgorithmDGEMV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,128 +12,134 @@

#include <sgpp/base/algorithm/GetAffectedBasisFunctions.hpp>

#include <sgpp/globaldef.hpp>

#include <vector>
#include <utility>
#include <iostream>

#include <sgpp/globaldef.hpp>


namespace SGPP {
namespace base {

/**
* Basic multiplaction with B and B^T on grids with no boundaries.
* If there are @f$N@f$ basis functions @f$\varphi(\vec{x})@f$ and @f$m@f$ data points, then B is a (Nxm) matrix, with
* @f[ (B)_{i,j} = \varphi_i(x_j). @f]
* (The common known name for this operation is the BLAS routine DGEMV.)
*
*/
template<class BASIS>
class AlgorithmDGEMV {
public:

/**
* Performs the DGEMV Operation on the grid
*
* This operation can be executed in parallel by setting the USEOMP define
*
* @param storage GridStorage object that contains the grid's points information
* @param basis a reference to a class that implements a specific basis
* @param source the coefficients of the grid points
* @param x the d-dimensional vector with data points (row-wise)
* @param result the result vector of the matrix vector multiplication
*/
void mult_transposed(GridStorage* storage, BASIS& basis, const DataVector& source, DataMatrix& x, DataVector& result) {
typedef std::vector<std::pair<size_t, float_t> > IndexValVector;

result.setAll(0.0);

/*
//THIS HAS TO WAIT UNTIL THE SUPPORT OF OMP 4.0 IS BETTER ON OLD SYSTEMS
#pragma omp declare reduction(accumulate : SGPP::base::DataVector : omp_out.add(omp_in)) \
initializer ( omp_priv = DataVector(omp_orig.getSize(), 0))
*/

#pragma omp parallel
{
size_t source_size = source.getSize();
DataVector privateResult(result);
DataVector line(x.getNcols());
IndexValVector vec;
GetAffectedBasisFunctions<BASIS> ga(storage);

privateResult.setAll(0.0);

/*
//THIS HAS TO WAIT UNTIL THE SUPPORT OF OMP 4.0 IS BETTER ON OLD SYSTEMS
#pragma omp for reduction(accumulate:result) schedule(static)
*/
#pragma omp for schedule(static)

for (size_t i = 0; i < source_size; i++) {
vec.clear();

x.getRow(i, line);

ga(basis, line, vec);

for (IndexValVector::iterator iter = vec.begin(); iter != vec.end(); iter++) {
privateResult[iter->first] += iter->second * source[i];
}
}

#pragma omp critical
{
result.add(privateResult);
}
}
namespace base {

/**
* Basic multiplaction with B and B^T on grids with no boundaries.
* If there are @f$N@f$ basis functions @f$\varphi(\vec{x})@f$ and @f$m@f$ data points, then B is a (Nxm) matrix, with
* @f[ (B)_{i,j} = \varphi_i(x_j). @f]
* (The common known name for this operation is the BLAS routine DGEMV.)
*
*/
template<class BASIS>
class AlgorithmDGEMV {
public:
/**
* Performs the DGEMV Operation on the grid
*
* This operation can be executed in parallel by setting the USEOMP define
*
* @param storage GridStorage object that contains the grid's points information
* @param basis a reference to a class that implements a specific basis
* @param source the coefficients of the grid points
* @param x the d-dimensional vector with data points (row-wise)
* @param result the result vector of the matrix vector multiplication
*/
void mult_transposed(GridStorage* storage, BASIS& basis,
const DataVector& source, DataMatrix& x,
DataVector& result) {
typedef std::vector<std::pair<size_t, float_t> > IndexValVector;

result.setAll(0.0);

/*
//THIS HAS TO WAIT UNTIL THE SUPPORT OF OMP 4.0 IS BETTER ON OLD SYSTEMS
#pragma omp declare reduction(accumulate : SGPP::base::DataVector : omp_out.add(omp_in)) \
initializer ( omp_priv = DataVector(omp_orig.getSize(), 0))
*/

#pragma omp parallel
{
size_t source_size = source.getSize();
DataVector privateResult(result);
DataVector line(x.getNcols());
IndexValVector vec;
GetAffectedBasisFunctions<BASIS> ga(storage);

privateResult.setAll(0.0);

/*
//THIS HAS TO WAIT UNTIL THE SUPPORT OF OMP 4.0 IS BETTER ON OLD SYSTEMS
#pragma omp for reduction(accumulate:result) schedule(static)
*/
#pragma omp for schedule(static)

for (size_t i = 0; i < source_size; i++) {
vec.clear();

x.getRow(i, line);

ga(basis, line, vec);

for (IndexValVector::iterator iter = vec.begin();
iter != vec.end();
iter++) {
privateResult[iter->first] += iter->second * source[i];
}
}

/**
* Performs the DGEMV Operation on the grid having a transposed matrix
*
* This operation can be executed in parallel by setting the USEOMP define
*
*
* @param storage GridStorage object that contains the grid's points information
* @param basis a reference to a class that implements a specific basis
* @param source the coefficients of the grid points
* @param x the d-dimensional vector with data points (row-wise)
* @param result the result vector of the matrix vector multiplication
*/
void mult(GridStorage* storage, BASIS& basis, const DataVector& source, DataMatrix& x, DataVector& result) {
typedef std::vector<std::pair<size_t, float_t> > IndexValVector;
#pragma omp critical
{
result.add(privateResult);
}
}
}

result.setAll(0.0);
/**
* Performs the DGEMV Operation on the grid having a transposed matrix
*
* This operation can be executed in parallel by setting the USEOMP define
*
*
* @param storage GridStorage object that contains the grid's points information
* @param basis a reference to a class that implements a specific basis
* @param source the coefficients of the grid points
* @param x the d-dimensional vector with data points (row-wise)
* @param result the result vector of the matrix vector multiplication
*/
void mult(GridStorage* storage, BASIS& basis, const DataVector& source,
DataMatrix& x, DataVector& result) {
typedef std::vector<std::pair<size_t, float_t> > IndexValVector;

#pragma omp parallel
{
size_t result_size = result.getSize();
result.setAll(0.0);

DataVector line(x.getNcols());
IndexValVector vec;
#pragma omp parallel
{
size_t result_size = result.getSize();

GetAffectedBasisFunctions<BASIS> ga(storage);
DataVector line(x.getNcols());
IndexValVector vec;

#pragma omp for schedule (static)
GetAffectedBasisFunctions<BASIS> ga(storage);

for (size_t i = 0; i < result_size; i++) {
vec.clear();
#pragma omp for schedule (static)

x.getRow(i, line);
for (size_t i = 0; i < result_size; i++) {
vec.clear();

ga(basis, line, vec);
x.getRow(i, line);

for (IndexValVector::iterator iter = vec.begin(); iter != vec.end(); iter++) {
result[i] += iter->second * source[iter->first];
}
}
}
}
};
ga(basis, line, vec);

for (IndexValVector::iterator iter = vec.begin();
iter != vec.end();
iter++) {
result[i] += iter->second * source[iter->first];
}
}
}
}
}
};

} // namespace base
} // namespace SGPP

#endif /* ALGORTIHMDGEMV_HPP */
Loading

0 comments on commit 018c341

Please sign in to comment.