ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/optimization/Problem.cpp
Revision: 1741
Committed: Tue Jun 5 18:02:44 2012 UTC (12 years, 10 months ago) by gezelter
Original Path: branches/development/src/optimization/Problem.cpp
File size: 879 byte(s)
Log Message:
Adding initial import of optimization library

File Contents

# Content
1 #include "config.h"
2 #include "optimization/Problem.hpp"
3
4 #ifdef IS_MPI
5 #include <mpi.h>
6 #endif
7
8
9 namespace QuantLib {
10 RealType Problem::DotProduct(DynamicVector<RealType>& v1,
11 DynamicVector<RealType>& v2){
12 RealType dp = dot(v1, v2);
13 #ifdef IS_MPI
14 // in parallel, we need to add up the contributions from all
15 // processors:
16 MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &dp, 1, MPI::REALTYPE,
17 MPI::SUM);
18 #endif
19 return dp;
20 }
21
22 RealType Problem::computeGradientNormValue(DynamicVector<RealType>& grad_f) {
23
24 RealType dot = grad_f.lengthSquare();
25 #ifdef IS_MPI
26 // in parallel, we need to add up the contributions from all
27 // processors:
28 MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &dot, 1, MPI::REALTYPE,
29 MPI::SUM);
30 #endif
31 return dot;
32
33 }
34 }

Properties

Name Value
svn:eol-style native