Renabled BLAS using ATLAS for Linux, fixed a variety of annoying warnings

release/4.3a0
Alex Cunningham 2010-05-21 17:59:26 +00:00
parent fa954ab55e
commit e8979dafad
19 changed files with 67 additions and 72 deletions

View File

@ -317,6 +317,7 @@
</target>
<target name="clean" path="wrap" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -476,7 +477,6 @@
</target>
<target name="testBayesTree.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testBayesTree.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -484,6 +484,7 @@
</target>
<target name="testSymbolicBayesNet.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSymbolicBayesNet.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -491,7 +492,6 @@
</target>
<target name="testSymbolicFactorGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSymbolicFactorGraph.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -683,7 +683,6 @@
</target>
<target name="testGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testGraph.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -739,6 +738,7 @@
</target>
<target name="testSimulated2D.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSimulated2D.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -786,7 +786,6 @@
</target>
<target name="testErrors.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testErrors.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -794,7 +793,6 @@
</target>
<target name="testDSF.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testDSF.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -810,12 +808,19 @@
</target>
<target name="testConstraintOptimizer.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testConstraintOptimizer.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="testBTree.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testBTree.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments>-j2</buildArguments>

View File

@ -41,15 +41,15 @@ namespace gtsam {
* leaf node with height 1
*/
Node(const value_type& keyValue) :
keyValue_(keyValue), height_(1) {
height_(1), keyValue_(keyValue) {
}
/**
* Create a node from two subtrees and a key value pair
*/
Node(const BTree& l, const value_type& keyValue, const BTree& r) :
left(l), keyValue_(keyValue), right(r),
height_(l.height() >= r.height() ? l.height() + 1 : r.height() + 1) {
height_(l.height() >= r.height() ? l.height() + 1 : r.height() + 1),
keyValue_(keyValue), left(l), right(r) {
}
inline const Key& key() const { return keyValue_.first;}

View File

@ -56,7 +56,7 @@ namespace gtsam {
BinaryConditional(const Symbol& key, const Symbol& parent, const std::vector<double>& cpt) :
Conditional(key) {
parents_.push_back(parent);
for( int i = 0 ; i < cpt.size() ; i++ )
for( size_t i = 0 ; i < cpt.size() ; i++ )
cpt_.push_back(1-cpt[i]); // p(!x|parents)
cpt_.insert(cpt_.end(),cpt.begin(),cpt.end()); // p(x|parents)
}

View File

@ -105,7 +105,7 @@ void FactorGraph<Factor>::push_back(const FactorGraph<Factor>& factors) {
/* ************************************************************************* */
template<class Factor>
void FactorGraph<Factor>::replace(int index, sharedFactor factor) {
void FactorGraph<Factor>::replace(size_t index, sharedFactor factor) {
if(index >= factors_.size())
throw invalid_argument(boost::str(boost::format(
"Factor graph does not contain a factor with index %d.") % index));
@ -321,7 +321,7 @@ template<class Factor> void FactorGraph<Factor>::checkGraphConsistency() const {
// Make sure each factor listed for a variable actually involves that variable
BOOST_FOREACH(const SymbolMap<list<int> >::value_type& var, indices_) {
BOOST_FOREACH(int i, var.second) {
BOOST_FOREACH(size_t i, var.second) {
if(i >= factors_.size()) {
cout << "*** Factor graph inconsistency: " << (string)var.first << " lists factor " <<
i << " but the graph does not contain this many factors." << endl;
@ -380,8 +380,8 @@ void FactorGraph<Factor>::split(const PredecessorMap<Key>& tree, FactorGraph<Fac
Key key1 = factor2->key1();
Key key2 = factor2->key2();
// if the tree contains the key
if (tree.find(key1) != tree.end() && tree.find(key1)->second.compare(key2) == 0 ||
tree.find(key2) != tree.end() && tree.find(key2)->second.compare(key1) == 0)
if ((tree.find(key1) != tree.end() && tree.find(key1)->second.compare(key2) == 0) ||
(tree.find(key2) != tree.end() && tree.find(key2)->second.compare(key1) == 0))
Ab1.push_back(factor2);
else
Ab2.push_back(factor2);

View File

@ -87,7 +87,7 @@ namespace gtsam {
void push_back(const FactorGraph<Factor>& factors);
/** replace a factor by index */
void replace(int index, sharedFactor factor);
void replace(size_t index, sharedFactor factor);
/** return keys in some random order */
Ordering keys() const;

View File

@ -59,7 +59,6 @@ namespace gtsam {
for ( rit=bayesNet.rbegin(); rit != bayesNet.rend(); ++rit )
this->insert(*rit, index);
int count = 0;
// add orphans to the bottom of the new tree
BOOST_FOREACH(sharedClique orphan, orphans) {

View File

@ -306,8 +306,8 @@ AM_LDFLAGS = -L../CppUnitLite -lCppUnitLite $(BOOST_LDFLAGS) $(boost_serializati
if USE_BLAS_LINUX
AM_CXXFLAGS += -DGT_USE_CBLAS
libgtsam_la_CPPFLAGS += -DGT_USE_CBLAS
AM_LDFLAGS += $(BLAS_LIBS) $(LIBS) $(FLIBS)
libgtsam_la_LDFLAGS += $(BLAS_LIBS) $(LIBS) $(FLIBS)
AM_LDFLAGS += -lcblas -latlas # If getting from script: $(BLAS_LIBS) $(LIBS) $(FLIBS)
libgtsam_la_LDFLAGS += -lcblas -latlas # $(BLAS_LIBS) $(LIBS) $(FLIBS)
endif
if USE_BLAS_MACOS

View File

@ -268,10 +268,10 @@ void transposeMultiplyAdd(double alpha, const Matrix& A, const Vector& e, SubVec
// ublas x += prod(trans(A),e) is terribly slow
// TODO: use BLAS
size_t m = A.size1(), n = A.size2();
for (int j = 0; j < n; j++) {
for (size_t j = 0; j < n; j++) {
const double * ei = e.data().begin();
const double * aij = A.data().begin() + j;
for (int i = 0; i < m; i++, aij+=n, ei++)
for (size_t i = 0; i < m; i++, aij+=n, ei++)
x(j) += alpha * (*aij) * (*ei);
}
}
@ -293,13 +293,6 @@ Vector column_(const Matrix& A, size_t j) {
// throw invalid_argument("Column index out of bounds!");
return column(A,j); // real boost version
// TODO: improve this
// size_t m = A.size1();
// Vector a(m);
// for (size_t i=0; i<m; ++i)
// a(i) = A(i,j);
// return a;
}
/* ************************************************************************* */
@ -348,7 +341,7 @@ Matrix sub(const Matrix& A, size_t i1, size_t i2, size_t j1, size_t j2) {
/* ************************************************************************* */
void insertSub(Matrix& big, const Matrix& small, size_t i, size_t j) {
// direct pointer method
size_t ib = big.size1(), jb = big.size2(),
size_t jb = big.size2(),
is = small.size1(), js = small.size2();
// pointer to start of window in big
@ -472,13 +465,13 @@ inline void householder_update_manual(Matrix &A, int j, double beta, const Vecto
}
void householder_update(Matrix &A, int j, double beta, const Vector& vjm) {
const size_t m = A.size1(), n = A.size2();
#if defined GT_USE_CBLAS
// CBLAS version not working, using manual approach
householder_update_manual(A,j,beta,vjm);
// // straight atlas version
// const size_t m = A.size1(), n = A.size2();
// const size_t mj = m-j;
//
// // find pointers to the data
@ -659,8 +652,9 @@ void householder(Matrix &A, size_t k) {
/* ************************************************************************* */
Vector backSubstituteUpper(const Matrix& U, const Vector& b, bool unit) {
size_t m = U.size1(), n = U.size2();
size_t n = U.size2();
#ifndef NDEBUG
size_t m = U.size1();
if (m!=n)
throw invalid_argument("backSubstituteUpper: U must be square");
#endif
@ -679,8 +673,9 @@ Vector backSubstituteUpper(const Matrix& U, const Vector& b, bool unit) {
/* ************************************************************************* */
Vector backSubstituteUpper(const Vector& b, const Matrix& U, bool unit) {
size_t m = U.size1(), n = U.size2();
size_t n = U.size2();
#ifndef NDEBUG
size_t m = U.size1();
if (m!=n)
throw invalid_argument("backSubstituteUpper: U must be square");
#endif
@ -699,8 +694,9 @@ Vector backSubstituteUpper(const Vector& b, const Matrix& U, bool unit) {
/* ************************************************************************* */
Vector backSubstituteLower(const Matrix& L, const Vector& b, bool unit) {
size_t m = L.size1(), n = L.size2();
size_t n = L.size2();
#ifndef NDEBUG
size_t m = U.size1();
if (m!=n)
throw invalid_argument("backSubstituteLower: L must be square");
#endif
@ -750,11 +746,12 @@ Matrix collect(const std::vector<const Matrix *>& matrices, size_t m, size_t n)
// if we have known and constant dimensions, use them
size_t dimA1 = m;
size_t dimA2 = n*matrices.size();
if (!m && !n)
if (!m && !n) {
BOOST_FOREACH(const Matrix* M, matrices) {
dimA1 = M->size1(); // TODO: should check if all the same !
dimA2 += M->size2();
}
}
// memcpy version
Matrix A(dimA1, dimA2);
@ -896,11 +893,11 @@ Matrix RtR(const Matrix &A)
/* ************************************************************************* */
Vector solve_ldl(const Matrix& M, const Vector& rhs) {
int N = M.size1(); // size of the matrix
unsigned int N = M.size1(); // size of the matrix
// count the nonzero entries above diagonal
double thresh = 1e-9;
size_t nrANZ = 0; // # of nonzeros on diagonal and upper triangular part of A
unsigned int nrANZ = 0; // # of nonzeros on diagonal and upper triangular part of A
for (size_t i=0; i<N; ++i) // rows
for (size_t j=i; j<N; ++j) // columns
if (fabs(M(i,j)) > thresh)
@ -950,7 +947,7 @@ Vector solve_ldl(const Matrix& M, const Vector& rhs) {
double * Lx = new double[nrLNZ];
int * Li = new int [nrLNZ];
int d = LDL_numeric (N, Ap, Ai, Ax, Lp, Parent, Lnz, Li, Lx, D, Y, Pattern,
size_t d = LDL_numeric (N, Ap, Ai, Ax, Lp, Parent, Lnz, Li, Lx, D, Y, Pattern,
Flag, NULL, NULL);
if (d == N) {

View File

@ -49,7 +49,7 @@ NonlinearConstraint1<Config, Key, X>::NonlinearConstraint1(
const LagrangeKey& lagrange_key,
bool isEquality) :
NonlinearConstraint<Config>(lagrange_key, dim_constraint, isEquality),
g_(boost::bind(g, _1)), G_(boost::bind(gradG, _1)), key_(key)
G_(boost::bind(gradG, _1)), g_(boost::bind(g, _1)), key_(key)
{
this->keys_.push_back(key);
}
@ -64,7 +64,7 @@ NonlinearConstraint1<Config, Key, X>::NonlinearConstraint1(
const LagrangeKey& lagrange_key,
bool isEquality) :
NonlinearConstraint<Config>(lagrange_key, dim_constraint, isEquality),
g_(g), G_(gradG), key_(key)
G_(gradG), g_(g), key_(key)
{
this->keys_.push_back(key);
}
@ -144,7 +144,7 @@ NonlinearConstraint2<Config, Key1, X1, Key2, X2>::NonlinearConstraint2(
const LagrangeKey& lagrange_key,
bool isEquality) :
NonlinearConstraint<Config>(lagrange_key, dim_constraint, isEquality),
g_(boost::bind(g, _1)), G1_(boost::bind(G1, _1)), G2_(boost::bind(G2, _1)),
G1_(boost::bind(G1, _1)), G2_(boost::bind(G2, _1)), g_(boost::bind(g, _1)),
key1_(key1), key2_(key2)
{
this->keys_.push_back(key1);
@ -163,7 +163,7 @@ NonlinearConstraint2<Config, Key1, X1, Key2, X2>::NonlinearConstraint2(
const LagrangeKey& lagrange_key,
bool isEquality) :
NonlinearConstraint<Config>(lagrange_key, dim_constraint, isEquality),
g_(g), G1_(G1), G2_(G2),
G1_(G1), G2_(G2), g_(g),
key1_(key1), key2_(key2)
{
this->keys_.push_back(key1);

View File

@ -67,9 +67,8 @@ namespace simulated3D {
Simulated3DMeasurement(const Vector& z,
const SharedGaussian& model, PoseKey& j1, PointKey j2) :
z_(z),
NonlinearFactor2<VectorConfig, PoseKey, Vector, PointKey, Vector> (
model, j1, j2) {
model, j1, j2), z_(z) {
}
Vector evaluateError(const Vector& x1, const Vector& x2, boost::optional<

View File

@ -22,7 +22,6 @@ namespace gtsam {
*/
template<class X>
Vector numericalGradient(double (*h)(const X&), const X& x, double delta=1e-5) {
double hx = h(x);
double factor = 1.0/(2.0*delta);
const size_t n = x.dim();
Vector d(n,0.0), g(n,0.0);

View File

@ -78,7 +78,7 @@ namespace gtsam {
GenericOdometry(const Point2& z, const SharedGaussian& model,
const Key& i1, const Key& i2) :
z_(z), NonlinearFactor2<Cfg, Key, Point2, Key, Point2> (model, i1, i2) {
NonlinearFactor2<Cfg, Key, Point2, Key, Point2> (model, i1, i2), z_(z) {
}
Vector evaluateError(const Point2& x1, const Point2& x2, boost::optional<
@ -100,7 +100,7 @@ namespace gtsam {
GenericMeasurement(const Point2& z, const SharedGaussian& model,
const XKey& i, const LKey& j) :
z_(z), NonlinearFactor2<Cfg, XKey, Point2, LKey, Point2> (model, i, j) {
NonlinearFactor2<Cfg, XKey, Point2, LKey, Point2> (model, i, j), z_(z) {
}
Vector evaluateError(const Point2& x1, const Point2& x2, boost::optional<

View File

@ -460,8 +460,8 @@ TEST( GaussianFactorGraph, combine)
GaussianFactorGraph fg2 = createGaussianFactorGraph();
// get sizes
int size1 = fg1.size();
int size2 = fg2.size();
size_t size1 = fg1.size();
size_t size2 = fg2.size();
// combine them
fg1.combine(fg2);
@ -479,8 +479,8 @@ TEST( GaussianFactorGraph, combine2)
GaussianFactorGraph fg2 = createGaussianFactorGraph();
// get sizes
int size1 = fg1.size();
int size2 = fg2.size();
size_t size1 = fg1.size();
size_t size2 = fg2.size();
// combine them
GaussianFactorGraph fg3 = GaussianFactorGraph::combine2(fg1, fg2);
@ -491,7 +491,7 @@ TEST( GaussianFactorGraph, combine2)
/* ************************************************************************* */
// print a vector of ints if needed for debugging
void print(vector<int> v) {
for (int k = 0; k < v.size(); k++)
for (size_t k = 0; k < v.size(); k++)
cout << v[k] << " ";
cout << endl;
}

View File

@ -795,19 +795,19 @@ TEST( matrix, svd_sort )
// update A, b
// A' \define A_{S}-ar and b'\define b-ad
// __attribute__ ((noinline)) // uncomment to prevent inlining when profiling
static void updateAb(Matrix& A, Vector& b, int j, const Vector& a,
const Vector& r, double d) {
const size_t m = A.size1(), n = A.size2();
for (int i = 0; i < m; i++) { // update all rows
double ai = a(i);
b(i) -= ai * d;
double *Aij = A.data().begin() + i * n + j + 1;
const double *rptr = r.data().begin() + j + 1;
// A(i,j+1:end) -= ai*r(j+1:end)
for (int j2 = j + 1; j2 < n; j2++, Aij++, rptr++)
*Aij -= ai * (*rptr);
}
}
//static void updateAb(Matrix& A, Vector& b, int j, const Vector& a,
// const Vector& r, double d) {
// const size_t m = A.size1(), n = A.size2();
// for (int i = 0; i < m; i++) { // update all rows
// double ai = a(i);
// b(i) -= ai * d;
// double *Aij = A.data().begin() + i * n + j + 1;
// const double *rptr = r.data().begin() + j + 1;
// // A(i,j+1:end) -= ai*r(j+1:end)
// for (int j2 = j + 1; j2 < n; j2++, Aij++, rptr++)
// *Aij -= ai * (*rptr);
// }
//}
/* ************************************************************************* */
TEST( matrix, weighted_elimination )

View File

@ -53,7 +53,6 @@ TEST(NoiseModel, constructors)
m.push_back(Isotropic::Precision(3, prc));
// test whiten
int i=0;
BOOST_FOREACH(Gaussian::shared_ptr mi, m)
CHECK(assert_equal(whitened,mi->whiten(unwhitened)));

View File

@ -139,7 +139,6 @@ namespace test2 {
/** jacobian for y, jacobianG(x,y) in y: -1 */
Matrix G2(const VecConfig& config, const list<Key>& keys) {
double x = config[keys.back()](0);
return Matrix_(1, 1, -1.0);
}

View File

@ -78,7 +78,6 @@ TEST( Pose2Graph, linearization )
0.0, 2.0, 0.0,
0.0, 0.0, 10.0);
double sigma = 1;
Vector b = Vector_(3,-0.1/sx,0.1/sy,0.0);
SharedDiagonal probModel1 = noiseModel::Unit::Create(3);
lfg_expected.add("x1", A1, "x2", A2, b, probModel1);

View File

@ -915,7 +915,6 @@ boost::shared_ptr<Graph2D> linearMapWarpGraph() {
/* ********************************************************************* */
TEST ( SQPOptimizer, map_warp_initLam ) {
bool verbose = false;
// get a graph
boost::shared_ptr<Graph2D> graph = linearMapWarpGraph();

View File

@ -65,7 +65,7 @@ namespace gtsam { namespace visualSLAM {
GenericProjectionFactor(const Point2& z,
const SharedGaussian& model, PosK j_pose,
LmK j_landmark, const shared_ptrK& K) :
z_(z), K_(K), Base(model, j_pose, j_landmark) {
Base(model, j_pose, j_landmark), z_(z), K_(K) {
}
/**