From a90b790eb13b034d59f7b0b501ed7f1856989525 Mon Sep 17 00:00:00 2001 From: Elina Tjioe Date: Tue, 13 Jan 2015 12:42:02 -0800 Subject: [PATCH 001/491] Readme file. --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..fb3a6aac3a --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# NPC complex + +These scripts demonstrate the use of [IMP](http://salilab.org/imp) in the modeling of the NPC complex using data as described in Frank Alber's 2007 NPC paper. + +The scripts work with the [IMP](http://salilab.org/imp) (version 385a178). + +## List of files and directories: + +- `data` contains all relevant data + + +## Running the IMP scripts for the NPC complex: + +## Information + +_Author(s)_: Elina Tjioe + +_License_: [LGPL](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +_Last known good IMP version_: [![build info](https://salilab.org/imp/systems/?sysstat=6)](http://salilab.org/imp/systems/) + +_Publications_: From a1b019ed96b109d3bd4161d769281e3525212c6d Mon Sep 17 00:00:00 2001 From: Elina Tjioe Date: Tue, 13 Jan 2015 12:42:57 -0800 Subject: [PATCH 002/491] Readme file. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fb3a6aac3a..d029652ca5 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ The scripts work with the [IMP](http://salilab.org/imp) (version 385a178). ## Running the IMP scripts for the NPC complex: + ## Information _Author(s)_: Elina Tjioe From b0c9539659140a80b635e0eda9562bbf6704abde Mon Sep 17 00:00:00 2001 From: Elina Tjioe Date: Tue, 13 Jan 2015 13:47:59 -0800 Subject: [PATCH 003/491] update file. --- README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d029652ca5..8b119dbd19 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,31 @@ These scripts demonstrate the use of [IMP](http://salilab.org/imp) in the modeling of the NPC complex using data as described in Frank Alber's 2007 NPC paper. The scripts work with the [IMP](http://salilab.org/imp) (version 385a178). +A default build of IMP compiled with IMP\_NPC\_codes should work, but for most effective sampling, it should +be built with [MPI](http://integrativemodeling.org/nightly/doc/html/namespaceIMP_1_1mpi.html) so that replica exchange can be used. ## List of files and directories: -- `data` contains all relevant data +- `data` contains all relevant data +- `IMP_NPC_codes` contains IMP codes for NPC restraints +- `NPC_papers` contains relevant NPC papers +- `scripts` + - `test_NPC_scoring_functions.py` the main IMP script modeling for NPC +## Compiling IMP with IMP\_NPC\_codes: +- Clone IMP version 385a178 +- copy IMP\_NPC\_codes/ProteinLocalizationRestraint.cpp to IMP/modules/core/src +- copy IMP\_NPC\_codes/ProteinLocalizationRestraint.h to IMP/modules/core/include +- copy IMP\_NPC\_codes/swig.i-in to IMP/modules/core/pyext +- Compile IMP ## Running the IMP scripts for the NPC complex: - +- `cd scripts` +- `python test_NPC_scoring_functions.py & > test_NPC_scoring_functions.out` (on a single processor; prepend `mpirun -np 6` or similar if you built IMP with MPI support) ## Information -_Author(s)_: Elina Tjioe +_Author(s)_: Elina Tjioe, Frank Alber _License_: [LGPL](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). This library is free software; you can redistribute it and/or @@ -25,3 +38,6 @@ version 2 of the License, or (at your option) any later version. _Last known good IMP version_: [![build info](https://salilab.org/imp/systems/?sysstat=6)](http://salilab.org/imp/systems/) _Publications_: + +- Frank Alber\*, Svetlana Dokudovskaya\*, et al, [The Molecular Architecture of the Nuclear Pore Complex](http://www.nature.com/nature/journal/v450/n7170/abs/nature06405.html), Nature 450, 695-701, 2007. + From 46bee2606a679bbdaffd0fdd203bf0c9272e03ac Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Mon, 23 Mar 2015 17:53:37 -0700 Subject: [PATCH 004/491] Make things look more like a normal IMP module. --- .imp_info.py | 3 + dependencies.py | 3 + include/ProteinLocalizationRestraint.h | 324 +++++++ pyext/swig.i-in | 14 + src/ProteinLocalizationRestraint.cpp | 1179 ++++++++++++++++++++++++ 5 files changed, 1523 insertions(+) create mode 100644 .imp_info.py create mode 100644 dependencies.py create mode 100644 include/ProteinLocalizationRestraint.h create mode 100644 pyext/swig.i-in create mode 100644 src/ProteinLocalizationRestraint.cpp diff --git a/.imp_info.py b/.imp_info.py new file mode 100644 index 0000000000..ccf5b728c0 --- /dev/null +++ b/.imp_info.py @@ -0,0 +1,3 @@ +{ + "name": "IMP.npc" +} diff --git a/dependencies.py b/dependencies.py new file mode 100644 index 0000000000..933d5de8ab --- /dev/null +++ b/dependencies.py @@ -0,0 +1,3 @@ +required_modules = 'core' +required_dependencies = '' +optional_dependencies = '' diff --git a/include/ProteinLocalizationRestraint.h b/include/ProteinLocalizationRestraint.h new file mode 100644 index 0000000000..c2a4b46952 --- /dev/null +++ b/include/ProteinLocalizationRestraint.h @@ -0,0 +1,324 @@ +/** + * \file IMP/npc/ProteinLocalizationRestraint.h + * \brief protein localization restraints + * + * Restrict max distance between at least one pair of particles of any + * two distinct types. It also handles multiple copies of the same particles. + * + * Copyright 2007-2015 IMP Inventors. All rights reserved. + * + */ + +#ifndef IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H +#define IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H + +#include +#include +#include +#include + +IMPNPC_BEGIN_NAMESPACE + +class IMPNPCEXPORT ZAxialPositionLowerRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double lower_bound_; + double sigma_; + bool consider_radius_; +public: + ZAxialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, + double lower_bound, bool consider_radius, double sigma=1); + ZAxialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(ZAxialPositionLowerRestraint);; +}; + + +class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double lower_bound_; + double sigma_; + bool consider_radius_; +public: + XYRadialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, + double lower_bound, bool consider_radius, double sigma=1); + XYRadialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(XYRadialPositionLowerRestraint);; +}; + + +class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double upper_bound_; + double sigma_; + bool consider_radius_; +public: + XYRadialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, + double upper_bound, bool consider_radius, double sigma=1); + XYRadialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(XYRadialPositionUpperRestraint);; +}; + + +class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double upper_bound_; + double sigma_; + bool consider_radius_; +public: + ZAxialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, + double upper_bound, bool consider_radius, double sigma=1); + ZAxialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(ZAxialPositionUpperRestraint);; +}; + + +class IMPNPCEXPORT ProteinContactRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double tolerance_factor_; + double sigma_; +public: + ProteinContactRestraint(Model *m, SingletonContainerAdaptor sc, + double tolerance_factor, double sigma=0.1); + ProteinContactRestraint(Model *m, + double tolerance_factor, double sigma=0.1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(ProteinContactRestraint);; +}; + + +class IMPNPCEXPORT ProteinChainRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double sigma_; +public: + ProteinChainRestraint(Model *m, SingletonContainerAdaptor sc, + double sigma=0.1); + ProteinChainRestraint(Model *m, + double sigma=0.1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(ProteinChainRestraint);; +}; + + +class IMPNPCEXPORT MembraneSurfaceLocationRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double R_; + double r_; + double sigma_; + double thickness_; +public: + MembraneSurfaceLocationRestraint(Model *m, SingletonContainerAdaptor sc, + double R, double r, double thickness, double sigma=2); + MembraneSurfaceLocationRestraint(Model *m, + double R, double r, double thickness, double sigma=2); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(MembraneSurfaceLocationRestraint);; +}; + + +class IMPNPCEXPORT PoreSideVolumeLocationRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double R_; + double r_; + double sigma_; + double thickness_; + bool consider_radius_; +public: + PoreSideVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, + double R, double r, double thickness, bool consider_radius, double sigma=2); + PoreSideVolumeLocationRestraint(Model *m, + double R, double r, double thickness, bool consider_radius, double sigma=2); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(PoreSideVolumeLocationRestraint);; +}; + + +class IMPNPCEXPORT PerinuclearVolumeLocationRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double R_; + double r_; + double sigma_; + double thickness_; + bool consider_radius_; +public: + PerinuclearVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, + double R, double r, double thickness, bool consider_radius, double sigma=2); + PerinuclearVolumeLocationRestraint(Model *m, + double R, double r, double thickness, bool consider_radius, double sigma=2); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(PerinuclearVolumeLocationRestraint);; +}; + + +class IMPNPCEXPORT AssemblySymmetryByDistanceRestraint : public Restraint +{ + IMP::base::PointerMember sc_; + double sigma_; +public: + AssemblySymmetryByDistanceRestraint(Model *m, SingletonContainerAdaptor sc, + double sigma=4); + AssemblySymmetryByDistanceRestraint(Model *m, + double sigma=4); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(AssemblySymmetryByDistanceRestraint);; +}; + + +class IMPNPCEXPORT AssemblySymmetryByDihedralRestraint + : public Restraint +{ + IMP::base::PointerMember sc_; + double sigma_; +public: + AssemblySymmetryByDihedralRestraint(Model *m, SingletonContainerAdaptor sc, + double sigma=0.1); + AssemblySymmetryByDihedralRestraint(Model *m, + double sigma=0.1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(AssemblySymmetryByDihedralRestraint);; +}; + + +class IMPNPCEXPORT ProteinProximityRestraint + : public Restraint +{ + IMP::base::PointerMember sc_; + double sigma_; + double max_dist_; +public: + ProteinProximityRestraint(Model *m, SingletonContainerAdaptor sc, + double max_dist, double sigma=0.1); + ProteinProximityRestraint(Model *m, + double max_dist, double sigma=0.1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(ProteinProximityRestraint);; +}; + + + +IMPNPC_END_NAMESPACE + +#endif /* IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H */ diff --git a/pyext/swig.i-in b/pyext/swig.i-in new file mode 100644 index 0000000000..0697b51ce7 --- /dev/null +++ b/pyext/swig.i-in @@ -0,0 +1,14 @@ +IMP_SWIG_OBJECT( IMP::npc, ZAxialPositionLowerRestraint, ZAxialPositionLowerRestraints); +IMP_SWIG_OBJECT( IMP::npc, ZAxialPositionUpperRestraint, ZAxialPositionUpperRestraints); +IMP_SWIG_OBJECT( IMP::npc, XYRadialPositionLowerRestraint, XYRadialPositionLowerRestraints); +IMP_SWIG_OBJECT( IMP::npc, XYRadialPositionUpperRestraint, XYRadialPositionUpperRestraints); +IMP_SWIG_OBJECT( IMP::npc, ProteinContactRestraint, ProteinContactRestraints); +IMP_SWIG_OBJECT( IMP::npc, ProteinChainRestraint, ProteinChainRestraints); +IMP_SWIG_OBJECT( IMP::npc, MembraneSurfaceLocationRestraint, MembraneSurfaceLocationRestraints); +IMP_SWIG_OBJECT( IMP::npc, PoreSideVolumeLocationRestraint, PoreSideVolumeLocationRestraints); +IMP_SWIG_OBJECT( IMP::npc, PerinuclearVolumeLocationRestraint, PerinuclearVolumeLocationRestraints); +IMP_SWIG_OBJECT( IMP::npc, AssemblySymmetryByDistanceRestraint, AssemblySymmetryByDistanceRestraints); +IMP_SWIG_OBJECT( IMP::npc, AssemblySymmetryByDihedralRestraint, AssemblySymmetryByDihedralRestraints); +IMP_SWIG_OBJECT( IMP::npc, ProteinProximityRestraint, ProteinProximityRestraints); + +%include "IMP/npc/ProteinLocalizationRestraint.h" diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp new file mode 100644 index 0000000000..cc1b466c84 --- /dev/null +++ b/src/ProteinLocalizationRestraint.cpp @@ -0,0 +1,1179 @@ +/** + * \file ProteinLocalizationRestraint.cpp \brief Connectivity restraint. + * + * Restrict max distance between at least one pair of particles of any + * two distinct types. + * + * Copyright 2007-2015 IMP Inventors. All rights reserved. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +IMPNPC_BEGIN_NAMESPACE + +namespace { +kernel::internal::StaticListContainer *get_list( + SingletonContainer *sc) { + kernel::internal::StaticListContainer *ret = + dynamic_cast< + kernel::internal::StaticListContainer *>( + sc); + if (!ret) { + IMP_THROW("Can only use the set and add methods when no container" + << " was passed on construction of ConnectivityRestraint.", + base::ValueException); + } + return ret; +} +} + +ZAxialPositionLowerRestraint::ZAxialPositionLowerRestraint(Model *m, + SingletonContainerAdaptor sc, + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + + +ZAxialPositionLowerRestraint::ZAxialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + + +void ZAxialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void ZAxialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void ZAxialPositionLowerRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +ZAxialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + double r = core::XYZR(all_particles[i]).get_radius(); + double z = core::XYZR(all_particles[i]).get_coordinate(2); + double z_down = consider_radius_ ? z - r : z; + double z_diff = z_down - lower_bound_; + if ( z_diff < 0 ) + { + v += z_diff*z_diff; + if ( accum ) + { + algebra::Vector3D dz; + dz[0] = dz[1] = 0; + dz[2] = 2*z_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + } + return v/sigma_; +} + + +ModelObjectsTemp ZAxialPositionLowerRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +XYRadialPositionLowerRestraint::XYRadialPositionLowerRestraint(Model *m, + SingletonContainerAdaptor sc, + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + + +XYRadialPositionLowerRestraint::XYRadialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + + +void XYRadialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "XY radial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void XYRadialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "XY radial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void XYRadialPositionLowerRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "XY radial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +XYRadialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + const double eps = 1e-9; + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + core::XYZR xyzr = core::XYZR(all_particles[i]); + double r = consider_radius_ ? xyzr.get_radius() : 0; + double x = xyzr.get_coordinate(0); + double y = xyzr.get_coordinate(1); + double radial = std::sqrt(x*x + y*y); + double z_diff = radial - r - lower_bound_; + if ( z_diff < 0 ) + { + v += z_diff*z_diff; + if ( accum ) + { + algebra::Vector3D dz; + if ( radial > eps ) + { + dz[0] = 2*z_diff*x/(radial*sigma_); + dz[1] = 2*z_diff*y/(radial*sigma_); + } + else + { + dz[0] = dz[1] = 0; + } + dz[2] = 0; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + } + return v/sigma_; +} + + +ModelObjectsTemp XYRadialPositionLowerRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +XYRadialPositionUpperRestraint::XYRadialPositionUpperRestraint(Model *m, + SingletonContainerAdaptor sc, + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + + +XYRadialPositionUpperRestraint::XYRadialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + + +void XYRadialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "XY Radial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void XYRadialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "XY Radial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void XYRadialPositionUpperRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "XY Radial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +XYRadialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + const double eps = 1e-9; + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + core::XYZR xyzr = core::XYZR(all_particles[i]); + double r = consider_radius_ ? xyzr.get_radius() : 0; + double x = xyzr.get_coordinate(0); + double y = xyzr.get_coordinate(1); + double radial = std::sqrt(x*x + y*y); + double z_diff = radial + r - upper_bound_; + if ( z_diff > 0 ) + { + v += z_diff*z_diff; + if ( accum ) + { + algebra::Vector3D dz; + if ( radial > eps ) + { + dz[0] = 2*z_diff*x/(radial*sigma_); + dz[1] = 2*z_diff*y/(radial*sigma_); + } + else + { + dz[0] = dz[1] = 0; + } + dz[2] = 0; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + } + return v/sigma_; +} + + +ModelObjectsTemp XYRadialPositionUpperRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, + SingletonContainerAdaptor sc, + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + + +ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + + +void ZAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void ZAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void ZAxialPositionUpperRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +ZAxialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0; + double z = core::XYZR(all_particles[i]).get_coordinate(2); + double z_up = z + r; + double z_diff = z_up - upper_bound_; + if ( z_diff > 0 ) + { + v += z_diff*z_diff; + if ( accum ) + { + algebra::Vector3D dz; + dz[0] = dz[1] = 0; + dz[2] = 2*z_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + } + return v/sigma_; +} + + +ModelObjectsTemp ZAxialPositionUpperRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +ProteinContactRestraint::ProteinContactRestraint(Model *m, + SingletonContainerAdaptor sc, + double tolerance_factor, double sigma) + : Restraint(m, "ProteinContactRestraint %1%") + , tolerance_factor_(tolerance_factor) + , sigma_(sigma) +{ + sc_ = sc; +} + + +ProteinContactRestraint::ProteinContactRestraint(Model *m, + double tolerance_factor, double sigma) + : Restraint(m, "ProteinContactRestraint %1%") + , tolerance_factor_(tolerance_factor) + , sigma_(sigma) +{ +} + + +void ProteinContactRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein contact list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void ProteinContactRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein contact list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void ProteinContactRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Protein contact list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +ProteinContactRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + std::vector der(all_particles.size()); + for ( unsigned int i = 0; i < der.size(); ++i ) + { + IMP::algebra::Vector3D &v = der[i]; + v[0] = v[1] = v[2] = 0; + } + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + core::XYZR i_xyz = core::XYZR(all_particles[i]); + for ( unsigned int j = i + 1; j < all_particles.size(); ++j ) + { + core::XYZR j_xyz = core::XYZR(all_particles[i]); + double lower_bound = tolerance_factor_*(i_xyz.get_radius() + j_xyz.get_radius()); + double dist = std::sqrt((i_xyz.get_coordinates() - j_xyz.get_coordinates()).get_squared_magnitude()); + double diff = dist - lower_bound; + if ( diff > 0 ) + { + v += diff*diff; + double dx = 2*diff*(j_xyz.get_coordinate(0) - i_xyz.get_coordinate(0))/dist; + double dy = 2*diff*(j_xyz.get_coordinate(1) - i_xyz.get_coordinate(1))/dist; + double dz = 2*diff*(j_xyz.get_coordinate(2) - i_xyz.get_coordinate(2))/dist; + der[j] += IMP::algebra::Vector3D(dx/sigma_, dy/sigma_, dz/sigma_); + } + } + } + if ( accum ) + { + for ( unsigned int i = 0; i < all_particles.size(); ++i ) + { + all_particles[i]->get_model()->add_to_coordinate_derivatives( + IMP::internal::get_index(all_particles[i]), der[i], *accum); + } + } + return v/sigma_; +} + + +ModelObjectsTemp ProteinContactRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +ProteinChainRestraint::ProteinChainRestraint(Model *m, + SingletonContainerAdaptor sc, + double sigma) + : Restraint(m, "ProteinChainRestraint %1%") + , sigma_(sigma) +{ + sc_ = sc; +} + + +ProteinChainRestraint::ProteinChainRestraint(Model *m, + double sigma) + : Restraint(m, "ProteinChainRestraint %1%") + , sigma_(sigma) +{ +} + + +void ProteinChainRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein chain list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void ProteinChainRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein chain list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void ProteinChainRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Protein chain list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +ProteinChainRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + std::vector der(all_particles.size()); + for ( unsigned int i = 0; i < der.size(); ++i ) + { + IMP::algebra::Vector3D &v = der[i]; + v[0] = v[1] = v[2] = 0; + } + for (unsigned int i = 1; i < all_particles.size(); ++i ) + { + core::XYZR i_current = core::XYZR(all_particles[i]); + core::XYZR i_previous = core::XYZR(all_particles[i - 1]); + double dist = std::sqrt((i_current.get_coordinates() - i_previous.get_coordinates()).get_squared_magnitude()); + double r = i_current.get_radius() + i_previous.get_radius(); + double diff = dist - r; + v += diff*diff; + double dx = 2*diff*(i_current.get_coordinate(0) - i_previous.get_coordinate(0))/dist; + double dy = 2*diff*(i_current.get_coordinate(1) - i_previous.get_coordinate(1))/dist; + double dz = 2*diff*(i_current.get_coordinate(2) - i_previous.get_coordinate(2))/dist; + der[i] += IMP::algebra::Vector3D(dx/sigma_, dy/sigma_, dz/sigma_); + } + if ( accum ) + { + for ( unsigned int i = 0; i < all_particles.size(); ++i ) + { + all_particles[i]->get_model()->add_to_coordinate_derivatives( + IMP::internal::get_index(all_particles[i]), der[i], *accum); + } + } + return v/sigma_; +} + + +ModelObjectsTemp ProteinChainRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + +namespace +{ + + +std::pair half_torus_distance(double x, double y, double z, double R, double r) +{ + const double eps = 1e-9; + double d_xy2 = x*x + y*y; + double d_xy = std::sqrt(d_xy2); + double d_tx, d_ty; + double d_txx, d_txy, d_tyy, d_tyx; + if ( d_xy > eps ) + { + d_tx = x - x/d_xy*R; + d_txx = 1 - R*(x*x/d_xy - d_xy)/d_xy2; + d_txy = -R*x*y/(d_xy2*d_xy); + d_ty = y - y/d_xy*R; + d_tyy = 1 - R*(y*y/d_xy - d_xy)/d_xy2; + d_tyx = -R*y*x/(d_xy2*d_xy); + } + else + { + d_tx = x - R; + d_txx = 1; + d_txy = 0; + d_ty = y; + d_tyy = 1; + d_tyx = 0; + } + if ( d_xy <= R ) + { + double denom = std::sqrt(z*z + d_tx*d_tx + d_ty*d_ty); + algebra::Vector3D der; + if ( denom > eps ) + { + der[0] = (d_tx*d_txx + d_ty*d_tyx)/denom; + der[1] = (d_tx*d_txy + d_ty*d_tyy)/denom; + der[2] = z/denom; + } + else + { + der[0] = (d_tx*d_txx + d_ty*d_tyx)/eps; + der[1] = (d_tx*d_txy + d_ty*d_tyy)/eps; + der[2] = z/eps; + } + return std::make_pair(denom - r, der); + } + else + { + double dz = z > 0 ? z - r : z + r; + double denom = std::sqrt(dz*dz + d_tx*d_tx + d_ty*d_ty); + algebra::Vector3D der; + if ( denom > eps ) + { + der[0] = -(d_tx*d_txx + d_ty*d_tyx)/denom; + der[1] = -(d_tx*d_txy + d_ty*d_tyy)/denom; + der[2] = dz/denom; + } + else + { + der[0] = -(d_tx*d_txx + d_ty*d_tyx)/eps; + der[1] = -(d_tx*d_txy + d_ty*d_tyy)/eps; + der[2] = dz/eps; + } + return std::make_pair(-denom, der); + } +} + + +} + + +MembraneSurfaceLocationRestraint::MembraneSurfaceLocationRestraint(Model *m, + SingletonContainerAdaptor sc, + double R, double r, double thickness, double sigma) + : Restraint(m, "MembraneSurfaceLocationRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) +{ + sc_ = sc; +} + + +MembraneSurfaceLocationRestraint::MembraneSurfaceLocationRestraint(Model *m, + double R, double r, double thickness, double sigma) + : Restraint(m, "MembraneSurfaceLocationRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) +{ +} + + +void MembraneSurfaceLocationRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void MembraneSurfaceLocationRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void MembraneSurfaceLocationRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Surface location list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +MembraneSurfaceLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + core::XYZ i_current = core::XYZ(all_particles[i]); + double z = i_current.get_coordinate(2); + if ( z > r_ ) + z = r_; + else if ( z < -r_ ) + z = -r_; + std::pair dist = half_torus_distance(i_current.get_coordinate(0), + i_current.get_coordinate(1), z, R_, r_); + if ( std::fabs(dist.first) > thickness_ ) + { + v += dist.first*dist.first; + if ( accum ) + { + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), + dist.second*2*dist.first/sigma_, *accum); + } + } + } + return v/sigma_; +} + + +ModelObjectsTemp MembraneSurfaceLocationRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, + SingletonContainerAdaptor sc, + double R, double r, double thickness, + bool consider_radius, double sigma) + : Restraint(m, "PoreSideVolumeLocationRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + + +PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, + double R, double r, double thickness, + bool consider_radius, double sigma) + : Restraint(m, "PoreSideVolumeLocationRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) + , consider_radius_(consider_radius) +{ +} + + +void PoreSideVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void PoreSideVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void PoreSideVolumeLocationRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Surface location list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +PerinuclearVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + core::XYZR i_current = core::XYZR(all_particles[i]); + double z = i_current.get_coordinate(2); + if ( z > r_ ) + z = r_; + else if ( z < -r_ ) + z = -r_; + std::pair dist = half_torus_distance(i_current.get_coordinate(0), + i_current.get_coordinate(1), z, R_, r_); + double radius = consider_radius_ ? i_current.get_radius() : 0; + dist.first += radius + thickness_; + if ( dist.first > 0 ) + { + v += dist.first*dist.first; + if ( accum ) + { + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), + dist.second*2*dist.first/sigma_, *accum); + } + } + } + return v/sigma_; +} + + +ModelObjectsTemp PoreSideVolumeLocationRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, + SingletonContainerAdaptor sc, + double R, double r, double thickness, + bool consider_radius, double sigma) + : Restraint(m, "PerinuclearVolumeLocationRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + + +PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, + double R, double r, double thickness, + bool consider_radius, double sigma) + : Restraint(m, "PerinuclearVolumeLocationRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) + , consider_radius_(consider_radius) +{ +} + + +void PerinuclearVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void PerinuclearVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void PerinuclearVolumeLocationRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Surface location list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +PoreSideVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + core::XYZR i_current = core::XYZR(all_particles[i]); + double z = i_current.get_coordinate(2); + if ( z > r_ ) + z = r_; + else if ( z < -r_ ) + z = -r_; + std::pair dist = half_torus_distance(i_current.get_coordinate(0), + i_current.get_coordinate(1), z, R_, r_); + double radius = consider_radius_ ? i_current.get_radius() : 0; + dist.first -= radius + thickness_; + if ( dist.first < 0 ) + { + v += dist.first*dist.first; + if ( accum ) + { + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), + dist.second*2*dist.first/sigma_, *accum); + } + } + } + return v/sigma_; +} + + +ModelObjectsTemp PerinuclearVolumeLocationRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +AssemblySymmetryByDistanceRestraint::AssemblySymmetryByDistanceRestraint(Model *m, + SingletonContainerAdaptor sc, + double sigma) + : Restraint(m, "AssemblySymmetryByDistanceRestraint %1%") + , sigma_(sigma) +{ + sc_ = sc; +} + + +AssemblySymmetryByDistanceRestraint::AssemblySymmetryByDistanceRestraint(Model *m, + double sigma) + : Restraint(m, "AssemblySymmetryByDistanceRestraint %1%") + , sigma_(sigma) +{ +} + + +void AssemblySymmetryByDistanceRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein group configuration list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void AssemblySymmetryByDistanceRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein group configuration list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void AssemblySymmetryByDistanceRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Protein group configuration list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +AssemblySymmetryByDistanceRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP_USAGE_CHECK(all_particles.size() == 4, "AssemblySymmetryByDistanceRestraint must contain exactly 4 particles"); + double d1 = (core::XYZ(all_particles[0]).get_coordinates() + - core::XYZ(all_particles[1]).get_coordinates()).get_magnitude(); + double d2 = (core::XYZ(all_particles[2]).get_coordinates() + - core::XYZ(all_particles[3]).get_coordinates()).get_magnitude(); + double diff = d1 - d2; + if ( accum ) + { + { + algebra::Vector3D v0 = core::XYZ(all_particles[0]).get_coordinates(); + algebra::Vector3D v1 = core::XYZ(all_particles[1]).get_coordinates(); + algebra::Vector3D der = diff*(v0 - v1)/(d1*sigma_); + all_particles[0]->get_model()->add_to_coordinate_derivatives( + IMP::internal::get_index(all_particles[0]), der, *accum); + all_particles[1]->get_model()->add_to_coordinate_derivatives( + IMP::internal::get_index(all_particles[1]), -der, *accum); + } + { + algebra::Vector3D v0 = core::XYZ(all_particles[2]).get_coordinates(); + algebra::Vector3D v1 = core::XYZ(all_particles[3]).get_coordinates(); + algebra::Vector3D der = diff*(v0 - v1)/(d2*sigma_); + all_particles[2]->get_model()->add_to_coordinate_derivatives( + IMP::internal::get_index(all_particles[2]), -der, *accum); + all_particles[3]->get_model()->add_to_coordinate_derivatives( + IMP::internal::get_index(all_particles[3]), der, *accum); + } + } + return diff*diff/sigma_; +} + + + +AssemblySymmetryByDihedralRestraint::AssemblySymmetryByDihedralRestraint(Model *m, + SingletonContainerAdaptor sc, + double sigma) + : Restraint(m, "AssemblySymmetryByDihedralRestraint %1%") + , sigma_(sigma) +{ + sc_ = sc; +} + + +AssemblySymmetryByDihedralRestraint::AssemblySymmetryByDihedralRestraint(Model *m, + double sigma) + : Restraint(m, "AssemblySymmetryByDihedralRestraint %1%") + , sigma_(sigma) +{ +} + + +void AssemblySymmetryByDihedralRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein group configuration list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void AssemblySymmetryByDihedralRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein group configuration list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void AssemblySymmetryByDihedralRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Protein group configuration list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +AssemblySymmetryByDihedralRestraint::unprotected_evaluate(DerivativeAccumulator * /*accum*/) const +{ + IMP_CHECK_OBJECT(sc_.get()); + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP_USAGE_CHECK(all_particles.size() == 8, "AssemblySymmetryByDihedralRestraint must contain exactly 8 particles"); + double a1 = IMP::core::get_dihedral(core::XYZ(all_particles[0]), + core::XYZ(all_particles[1]), core::XYZ(all_particles[2]), + core::XYZ(all_particles[3])); + double a2 = IMP::core::get_dihedral(core::XYZ(all_particles[4]), + core::XYZ(all_particles[5]), core::XYZ(all_particles[6]), + core::XYZ(all_particles[7])); + double diff = a1 - a2; + return diff*diff/sigma_; +} + + +ModelObjectsTemp AssemblySymmetryByDistanceRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + +ModelObjectsTemp AssemblySymmetryByDihedralRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + + +ProteinProximityRestraint::ProteinProximityRestraint(Model *m, + SingletonContainerAdaptor sc, + double max_dist, double sigma) + : Restraint(m, "ProteinProximityRestraint %1%") + , sigma_(sigma) + , max_dist_(max_dist) +{ + sc_ = sc; +} + + +ProteinProximityRestraint::ProteinProximityRestraint(Model *m, + double max_dist, double sigma) + : Restraint(m, "ProteinProximityRestraint %1%") + , sigma_(sigma) + , max_dist_(max_dist) +{ +} + + +void ProteinProximityRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein group configuration list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void ProteinProximityRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new kernel::internal::StaticListContainer( + ps[0]->get_model(), "Protein group configuration list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void ProteinProximityRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new kernel::internal::StaticListContainer( + ps->get_model(), "Protein group configuration list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + + +double +ProteinProximityRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + IMP::kernel::ParticlesTemp all_particles = sc_->get(); + std::vector der(all_particles.size()); + for ( unsigned int i = 0; i < der.size(); ++i ) + { + IMP::algebra::Vector3D &v = der[i]; + v[0] = v[1] = v[2] = 0; + } + double v = 0; + for ( size_t i = 0; i + 1 < all_particles.size(); ++i ) + for ( size_t j = i + 1; j < all_particles.size(); ++j ) + { + double m = (core::XYZ(all_particles[i]).get_coordinates() + - core::XYZ(all_particles[j]).get_coordinates()).get_magnitude(); + double d = m - max_dist_; + if ( d > 0 ) + { + v += d*d; + double dx = 2*d*(core::XYZ(all_particles[j]).get_coordinate(0) - core::XYZ(all_particles[i]).get_coordinate(0))/m; + double dy = 2*d*(core::XYZ(all_particles[j]).get_coordinate(1) - core::XYZ(all_particles[i]).get_coordinate(1))/m; + double dz = 2*d*(core::XYZ(all_particles[j]).get_coordinate(2) - core::XYZ(all_particles[i]).get_coordinate(2))/m; + der[j] += IMP::algebra::Vector3D(dx/sigma_, dy/sigma_, dz/sigma_); + } + } + if ( accum ) + { + for ( unsigned int i = 0; i < all_particles.size(); ++i ) + { + all_particles[i]->get_model()->add_to_coordinate_derivatives( + IMP::internal::get_index(all_particles[i]), der[i], *accum); + } + } + return v/sigma_; +} + + +ModelObjectsTemp ProteinProximityRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + +IMPNPC_END_NAMESPACE From ea4c964d63731a0cad7ffa48de7d8b324bda2a03 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Mon, 23 Mar 2015 17:54:34 -0700 Subject: [PATCH 005/491] Ignore generated files. --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..c63912f2de --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.pyc +*~ +~.orig +*~ +.*.sw? +CMakeLists.txt +CMakeModules +Files.cmake From 27189c5eb87ad3cb3d53d37b3fc5bc1743945187 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Mon, 23 Mar 2015 17:59:44 -0700 Subject: [PATCH 006/491] IMP_NPC_CODES no longer exists; update build info. --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8b119dbd19..37d63abede 100644 --- a/README.md +++ b/README.md @@ -3,22 +3,19 @@ These scripts demonstrate the use of [IMP](http://salilab.org/imp) in the modeling of the NPC complex using data as described in Frank Alber's 2007 NPC paper. The scripts work with the [IMP](http://salilab.org/imp) (version 385a178). -A default build of IMP compiled with IMP\_NPC\_codes should work, but for most effective sampling, it should +A default build of IMP compiled with the IMP::npc module should work, but for most effective sampling, it should be built with [MPI](http://integrativemodeling.org/nightly/doc/html/namespaceIMP_1_1mpi.html) so that replica exchange can be used. ## List of files and directories: - `data` contains all relevant data -- `IMP_NPC_codes` contains IMP codes for NPC restraints - `NPC_papers` contains relevant NPC papers - `scripts` - `test_NPC_scoring_functions.py` the main IMP script modeling for NPC -## Compiling IMP with IMP\_NPC\_codes: +## Compiling IMP with NPC-specific module: - Clone IMP version 385a178 -- copy IMP\_NPC\_codes/ProteinLocalizationRestraint.cpp to IMP/modules/core/src -- copy IMP\_NPC\_codes/ProteinLocalizationRestraint.h to IMP/modules/core/include -- copy IMP\_NPC\_codes/swig.i-in to IMP/modules/core/pyext +- Clone this repository into imp/modules/npc/. - Compile IMP ## Running the IMP scripts for the NPC complex: @@ -35,8 +32,6 @@ modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -_Last known good IMP version_: [![build info](https://salilab.org/imp/systems/?sysstat=6)](http://salilab.org/imp/systems/) - _Publications_: - Frank Alber\*, Svetlana Dokudovskaya\*, et al, [The Molecular Architecture of the Nuclear Pore Complex](http://www.nature.com/nature/journal/v450/n7170/abs/nature06405.html), Nature 450, 695-701, 2007. From 05037577539695429ebfca8f0ec213d8f9e8de4a Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Tue, 14 Apr 2015 20:43:11 -0700 Subject: [PATCH 007/491] Remove kernel namespace. --- src/ProteinLocalizationRestraint.cpp | 102 +++++++++++++-------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index cc1b466c84..f01644b485 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -22,11 +22,11 @@ IMPNPC_BEGIN_NAMESPACE namespace { -kernel::internal::StaticListContainer *get_list( +IMP::internal::StaticListContainer *get_list( SingletonContainer *sc) { - kernel::internal::StaticListContainer *ret = + IMP::internal::StaticListContainer *ret = dynamic_cast< - kernel::internal::StaticListContainer *>( + IMP::internal::StaticListContainer *>( sc); if (!ret) { IMP_THROW("Can only use the set and add methods when no container" @@ -61,7 +61,7 @@ ZAxialPositionLowerRestraint::ZAxialPositionLowerRestraint(Model *m, void ZAxialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Z axial list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -69,7 +69,7 @@ void ZAxialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { void ZAxialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Z axial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -77,7 +77,7 @@ void ZAxialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { void ZAxialPositionLowerRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Z axial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -89,7 +89,7 @@ ZAxialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) { IMP_CHECK_OBJECT(sc_.get()); double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { double r = core::XYZR(all_particles[i]).get_radius(); @@ -145,7 +145,7 @@ XYRadialPositionLowerRestraint::XYRadialPositionLowerRestraint(Model *m, void XYRadialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "XY radial list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -153,7 +153,7 @@ void XYRadialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { void XYRadialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "XY radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -161,7 +161,7 @@ void XYRadialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { void XYRadialPositionLowerRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "XY radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -174,7 +174,7 @@ XYRadialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accu IMP_CHECK_OBJECT(sc_.get()); const double eps = 1e-9; double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { core::XYZR xyzr = core::XYZR(all_particles[i]); @@ -240,7 +240,7 @@ XYRadialPositionUpperRestraint::XYRadialPositionUpperRestraint(Model *m, void XYRadialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "XY Radial list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -248,7 +248,7 @@ void XYRadialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { void XYRadialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "XY Radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -256,7 +256,7 @@ void XYRadialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { void XYRadialPositionUpperRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "XY Radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -269,7 +269,7 @@ XYRadialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accu IMP_CHECK_OBJECT(sc_.get()); const double eps = 1e-9; double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { core::XYZR xyzr = core::XYZR(all_particles[i]); @@ -335,7 +335,7 @@ ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, void ZAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Z axial list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -343,7 +343,7 @@ void ZAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { void ZAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Z axial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -351,7 +351,7 @@ void ZAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { void ZAxialPositionUpperRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Z axial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -363,7 +363,7 @@ ZAxialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) { IMP_CHECK_OBJECT(sc_.get()); double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0; @@ -417,7 +417,7 @@ ProteinContactRestraint::ProteinContactRestraint(Model *m, void ProteinContactRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein contact list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -425,7 +425,7 @@ void ProteinContactRestraint::set_particles(const ParticlesTemp &ps) { void ProteinContactRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein contact list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -433,7 +433,7 @@ void ProteinContactRestraint::add_particles(const ParticlesTemp &ps) { void ProteinContactRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Protein contact list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -445,7 +445,7 @@ ProteinContactRestraint::unprotected_evaluate(DerivativeAccumulator *accum) cons { IMP_CHECK_OBJECT(sc_.get()); double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); std::vector der(all_particles.size()); for ( unsigned int i = 0; i < der.size(); ++i ) { @@ -512,7 +512,7 @@ ProteinChainRestraint::ProteinChainRestraint(Model *m, void ProteinChainRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein chain list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -520,7 +520,7 @@ void ProteinChainRestraint::set_particles(const ParticlesTemp &ps) { void ProteinChainRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein chain list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -528,7 +528,7 @@ void ProteinChainRestraint::add_particles(const ParticlesTemp &ps) { void ProteinChainRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Protein chain list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -540,7 +540,7 @@ ProteinChainRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); std::vector der(all_particles.size()); for ( unsigned int i = 0; i < der.size(); ++i ) { @@ -678,7 +678,7 @@ MembraneSurfaceLocationRestraint::MembraneSurfaceLocationRestraint(Model *m, void MembraneSurfaceLocationRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -686,7 +686,7 @@ void MembraneSurfaceLocationRestraint::set_particles(const ParticlesTemp &ps) { void MembraneSurfaceLocationRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -694,7 +694,7 @@ void MembraneSurfaceLocationRestraint::add_particles(const ParticlesTemp &ps) { void MembraneSurfaceLocationRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Surface location list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -706,7 +706,7 @@ MembraneSurfaceLocationRestraint::unprotected_evaluate(DerivativeAccumulator *ac { IMP_CHECK_OBJECT(sc_.get()); double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { core::XYZ i_current = core::XYZ(all_particles[i]); @@ -770,7 +770,7 @@ PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, void PoreSideVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -778,7 +778,7 @@ void PoreSideVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { void PoreSideVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -786,7 +786,7 @@ void PoreSideVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) { void PoreSideVolumeLocationRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Surface location list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -798,7 +798,7 @@ PerinuclearVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator * { IMP_CHECK_OBJECT(sc_.get()); double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { core::XYZR i_current = core::XYZR(all_particles[i]); @@ -864,7 +864,7 @@ PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, void PerinuclearVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -872,7 +872,7 @@ void PerinuclearVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) void PerinuclearVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -880,7 +880,7 @@ void PerinuclearVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) void PerinuclearVolumeLocationRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Surface location list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -892,7 +892,7 @@ PoreSideVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *acc { IMP_CHECK_OBJECT(sc_.get()); double v = 0; - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { core::XYZR i_current = core::XYZR(all_particles[i]); @@ -948,7 +948,7 @@ AssemblySymmetryByDistanceRestraint::AssemblySymmetryByDistanceRestraint(Model * void AssemblySymmetryByDistanceRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -956,7 +956,7 @@ void AssemblySymmetryByDistanceRestraint::set_particles(const ParticlesTemp &ps) void AssemblySymmetryByDistanceRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -964,7 +964,7 @@ void AssemblySymmetryByDistanceRestraint::add_particles(const ParticlesTemp &ps) void AssemblySymmetryByDistanceRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Protein group configuration list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -975,7 +975,7 @@ double AssemblySymmetryByDistanceRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); IMP_USAGE_CHECK(all_particles.size() == 4, "AssemblySymmetryByDistanceRestraint must contain exactly 4 particles"); double d1 = (core::XYZ(all_particles[0]).get_coordinates() - core::XYZ(all_particles[1]).get_coordinates()).get_magnitude(); @@ -1028,7 +1028,7 @@ AssemblySymmetryByDihedralRestraint::AssemblySymmetryByDihedralRestraint(Model * void AssemblySymmetryByDihedralRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -1036,7 +1036,7 @@ void AssemblySymmetryByDihedralRestraint::set_particles(const ParticlesTemp &ps) void AssemblySymmetryByDihedralRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -1044,7 +1044,7 @@ void AssemblySymmetryByDihedralRestraint::add_particles(const ParticlesTemp &ps) void AssemblySymmetryByDihedralRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Protein group configuration list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -1055,7 +1055,7 @@ double AssemblySymmetryByDihedralRestraint::unprotected_evaluate(DerivativeAccumulator * /*accum*/) const { IMP_CHECK_OBJECT(sc_.get()); - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); IMP_USAGE_CHECK(all_particles.size() == 8, "AssemblySymmetryByDihedralRestraint must contain exactly 8 particles"); double a1 = IMP::core::get_dihedral(core::XYZ(all_particles[0]), core::XYZ(all_particles[1]), core::XYZ(all_particles[2]), @@ -1107,7 +1107,7 @@ ProteinProximityRestraint::ProteinProximityRestraint(Model *m, void ProteinProximityRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); @@ -1115,7 +1115,7 @@ void ProteinProximityRestraint::set_particles(const ParticlesTemp &ps) { void ProteinProximityRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -1123,7 +1123,7 @@ void ProteinProximityRestraint::add_particles(const ParticlesTemp &ps) { void ProteinProximityRestraint::add_particle(Particle *ps) { if (!sc_) { - sc_ = new kernel::internal::StaticListContainer( + sc_ = new IMP::internal::StaticListContainer( ps->get_model(), "Protein group configuration list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); @@ -1134,7 +1134,7 @@ double ProteinProximityRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); - IMP::kernel::ParticlesTemp all_particles = sc_->get(); + IMP::ParticlesTemp all_particles = sc_->get(); std::vector der(all_particles.size()); for ( unsigned int i = 0; i < der.size(); ++i ) { From f7120cbe55b02e96eeb2cb569c95731176b131c5 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 15 Apr 2015 19:42:23 -0700 Subject: [PATCH 008/491] Remove use of base namespace. --- include/ProteinLocalizationRestraint.h | 26 +++++++++++++------------- src/ProteinLocalizationRestraint.cpp | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/ProteinLocalizationRestraint.h b/include/ProteinLocalizationRestraint.h index c2a4b46952..3a76e94264 100644 --- a/include/ProteinLocalizationRestraint.h +++ b/include/ProteinLocalizationRestraint.h @@ -12,7 +12,7 @@ #ifndef IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H #define IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H -#include +#include #include #include #include @@ -21,7 +21,7 @@ IMPNPC_BEGIN_NAMESPACE class IMPNPCEXPORT ZAxialPositionLowerRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double lower_bound_; double sigma_; bool consider_radius_; @@ -46,7 +46,7 @@ class IMPNPCEXPORT ZAxialPositionLowerRestraint : public Restraint class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double lower_bound_; double sigma_; bool consider_radius_; @@ -71,7 +71,7 @@ class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double upper_bound_; double sigma_; bool consider_radius_; @@ -96,7 +96,7 @@ class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double upper_bound_; double sigma_; bool consider_radius_; @@ -121,7 +121,7 @@ class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint class IMPNPCEXPORT ProteinContactRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double tolerance_factor_; double sigma_; public: @@ -145,7 +145,7 @@ class IMPNPCEXPORT ProteinContactRestraint : public Restraint class IMPNPCEXPORT ProteinChainRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double sigma_; public: ProteinChainRestraint(Model *m, SingletonContainerAdaptor sc, @@ -168,7 +168,7 @@ class IMPNPCEXPORT ProteinChainRestraint : public Restraint class IMPNPCEXPORT MembraneSurfaceLocationRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double R_; double r_; double sigma_; @@ -194,7 +194,7 @@ class IMPNPCEXPORT MembraneSurfaceLocationRestraint : public Restraint class IMPNPCEXPORT PoreSideVolumeLocationRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double R_; double r_; double sigma_; @@ -221,7 +221,7 @@ class IMPNPCEXPORT PoreSideVolumeLocationRestraint : public Restraint class IMPNPCEXPORT PerinuclearVolumeLocationRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double R_; double r_; double sigma_; @@ -248,7 +248,7 @@ class IMPNPCEXPORT PerinuclearVolumeLocationRestraint : public Restraint class IMPNPCEXPORT AssemblySymmetryByDistanceRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double sigma_; public: AssemblySymmetryByDistanceRestraint(Model *m, SingletonContainerAdaptor sc, @@ -272,7 +272,7 @@ class IMPNPCEXPORT AssemblySymmetryByDistanceRestraint : public Restraint class IMPNPCEXPORT AssemblySymmetryByDihedralRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double sigma_; public: AssemblySymmetryByDihedralRestraint(Model *m, SingletonContainerAdaptor sc, @@ -296,7 +296,7 @@ class IMPNPCEXPORT AssemblySymmetryByDihedralRestraint class IMPNPCEXPORT ProteinProximityRestraint : public Restraint { - IMP::base::PointerMember sc_; + IMP::PointerMember sc_; double sigma_; double max_dist_; public: diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index f01644b485..d58fdc660d 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -31,7 +31,7 @@ IMP::internal::StaticListContainer *get_list( if (!ret) { IMP_THROW("Can only use the set and add methods when no container" << " was passed on construction of ConnectivityRestraint.", - base::ValueException); + ValueException); } return ret; } From 44e1aa10affeaec3819128449cd74749e18c4707 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 18 Nov 2015 16:33:39 -0800 Subject: [PATCH 009/491] First stage of CompositeRestraint. --- include/CompositeRestraint.h | 76 +++++++++++++++++++++ pyext/swig.i-in | 2 + src/CompositeRestraint.cpp | 114 +++++++++++++++++++++++++++++++ test/test_composite_restraint.py | 39 +++++++++++ 4 files changed, 231 insertions(+) create mode 100644 include/CompositeRestraint.h create mode 100644 src/CompositeRestraint.cpp create mode 100644 test/test_composite_restraint.py diff --git a/include/CompositeRestraint.h b/include/CompositeRestraint.h new file mode 100644 index 0000000000..c3004c3c30 --- /dev/null +++ b/include/CompositeRestraint.h @@ -0,0 +1,76 @@ +/** + * \file IMP/npc/CompositeRestraint.h \brief Composite restraint. + * + * Copyright 2007-2015 IMP Inventors. All rights reserved. + * + */ + +#ifndef IMPNPC_COMPOSITE_RESTRAINT_H +#define IMPNPC_COMPOSITE_RESTRAINT_H + +#include + +#include +#include +#include + +IMPNPC_BEGIN_NAMESPACE + +//! Score a set of particles that form a composite +/** Similarly to IMP::core::ConnectivityRestraint, this ensures that a set + of Particles remains connected, but allows how they are connected to change + (for example, A-B-C would score as well as B-A-C). However, unlike that + restraint, it acts on Particle type (in the case where there are several + distinct Particles of the same type) and allows the stoichoimetry to change + (For example, A1-B1-C1 would score similarly to A1-B2-C2 or A1-B1-B2-C1). + + To use, first create the restraint and then call add_type() for each + distinct protein type, e.g. to enforce the composite ABC where there are + two copies of protein A and B and a single copy of protein C use: + \begin{code} + add_type([A1, A2]) + add_type([B1, B2]) + add_type([C1]) + \end{code} + + The restraint scores by computing the complete graph connecting all the + particles (where the particles are the vertices and the edges are the + value of the PairScore), then calculating the minimum spanning tree, and + then using the lowest scoring subgraph that includes at least one of each + protein type. This is made much more efficient if the restraint's maximum + score is set (set_maximum_score()). + + \see IMP::core::ConnectivityRestraint + \see IMP::core::MSConnectivityRestraint + */ +class IMPNPCEXPORT CompositeRestraint : public Restraint { + typedef std::pair TypedParticle; + PointerMember ps_; + std::vector tps_; + int num_particle_types_; + + public: + //! Create with the given PairScore + CompositeRestraint(Model *m, PairScore *ps) + : Restraint(m, "CompositeRestraint %1%"), ps_(ps), + num_particle_types_(0) {} + + //! Add all Particles of a single type + /** The restraint will ensure that at least one Particle of each type + is present in the composite. */ + void add_type(ParticleIndexes ps) { + for (ParticleIndexes::const_iterator it = ps.begin(); it != ps.end(); + ++it) { + tps_.push_back(TypedParticle(num_particle_types_, *it)); + } + ++num_particle_types_; + } + + double unprotected_evaluate(DerivativeAccumulator *accum) const IMP_OVERRIDE; + ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE; + IMP_OBJECT_METHODS(CompositeRestraint); +}; + +IMPNPC_END_NAMESPACE + +#endif /* IMPNPC_COMPOSITE_RESTRAINT_H */ diff --git a/pyext/swig.i-in b/pyext/swig.i-in index 0697b51ce7..4625125244 100644 --- a/pyext/swig.i-in +++ b/pyext/swig.i-in @@ -10,5 +10,7 @@ IMP_SWIG_OBJECT( IMP::npc, PerinuclearVolumeLocationRestraint, PerinuclearVolume IMP_SWIG_OBJECT( IMP::npc, AssemblySymmetryByDistanceRestraint, AssemblySymmetryByDistanceRestraints); IMP_SWIG_OBJECT( IMP::npc, AssemblySymmetryByDihedralRestraint, AssemblySymmetryByDihedralRestraints); IMP_SWIG_OBJECT( IMP::npc, ProteinProximityRestraint, ProteinProximityRestraints); +IMP_SWIG_OBJECT( IMP::npc, CompositeRestraint, CompositeRestraints); %include "IMP/npc/ProteinLocalizationRestraint.h" +%include "IMP/npc/CompositeRestraint.h" diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp new file mode 100644 index 0000000000..85d51f1021 --- /dev/null +++ b/src/CompositeRestraint.cpp @@ -0,0 +1,114 @@ +/** + * \file CompositeRestraint.cpp \brief Composite restraint. + * + * Copyright 2007-2015 IMP Inventors. All rights reserved. + * + */ + +#include +#include +#include + +#include + +IMPNPC_BEGIN_NAMESPACE + +namespace { + + typedef std::pair TypedParticle; + typedef std::vector TypedParticles; + + /* Graph type used for the original fully-connected graph */ + typedef boost::adjacency_matrix > FullGraph; + typedef boost::property_map::type + FullGraphWeightMap; + typedef boost::graph_traits::edge_descriptor FullGraphEdge; + + /* Graph type used for MST */ + typedef boost::adjacency_list > Graph; + typedef boost::graph_traits::edge_descriptor Edge; + typedef Graph::edge_property_type Weight; + typedef boost::graph_traits::vertex_descriptor Vertex; + + /* debugging */ + void show_graph(const Graph &g, const TypedParticles &tps, Model *m) { + std::cout << boost::num_vertices(g) << " vertices" << std::endl; + std::cout << boost::num_edges(g) << " edges = "; + boost::graph_traits::edge_iterator ei, ei_end; + for (boost::tie(ei, ei_end) = boost::edges(g); ei != ei_end; ++ei) { + int s = boost::source(*ei, g); + int t = boost::target(*ei, g); + std::cout << "(" << m->get_particle_name(tps[s].second) + << "," << m->get_particle_name(tps[t].second) << ") "; + } + std::cout << std::endl; + } + + void compute_mst(Model *m, const TypedParticles &tps, + PairScore *ps, Graph &g) { + // Create fully connected graph + FullGraph full_g(tps.size()); + for (unsigned int i = 0; i < tps.size(); ++i) { + for (unsigned int j = 0; j < i; ++j) { + double d = ps->evaluate_index(m, + ParticleIndexPair(tps[i].second, tps[j].second), + nullptr); +// std::cout << "add edge " << i << "," << j << " => " << d << std::endl; + boost::add_edge(i, j, d, full_g); + } + } + std::vector mst; + boost::kruskal_minimum_spanning_tree(full_g, std::back_inserter(mst)); + + // Build new graph containing only the mst edges + FullGraphWeightMap weight_map = boost::get(boost::edge_weight, full_g); + for (std::vector::const_iterator it = mst.begin(); + it != mst.end(); ++it) { +// std::cout << boost::source(*it, full_g) << " " << boost::target(*it, full_g) << " " << weight_map[*it] << std::endl; + boost::add_edge(boost::source(*it, full_g), + boost::target(*it, full_g), weight_map[*it], g); + } + } + + void generate_connected_subgraphs( + std::set vertices_not_yet_considered, + std::vector subset_so_far, std::set neighbors, + Graph &g, std::set &min_vertices, double &min_score) { + } + + double get_best_scoring_subgraph(Graph &g, double max_score) { + double min_score = max_score; + std::set min_vertices; + //generate_connected_subgraphs(g, min_vertices, min_score); + // score over all edges that connect min_vertices in g + } + +} // anonymous namespace + +double CompositeRestraint::unprotected_evaluate(DerivativeAccumulator *accum) + const { + IMP_CHECK_OBJECT(ps_.get()); + Graph g; + compute_mst(get_model(), tps_, ps_, g); + show_graph(g, tps_, get_model()); + double score = get_best_scoring_subgraph(g, get_maximum_score()); + return score; +} + +ModelObjectsTemp CompositeRestraint::do_get_inputs() const { + ModelObjectsTemp ret; + ret.reserve(tps_.size()); + Model *m = get_model(); + for (TypedParticles::const_iterator it = tps_.begin(); it != tps_.end(); + ++it) { + ret.push_back(m->get_particle(it->second)); + } + return ret; +} + +IMPNPC_END_NAMESPACE diff --git a/test/test_composite_restraint.py b/test/test_composite_restraint.py new file mode 100644 index 0000000000..8039a60bb5 --- /dev/null +++ b/test/test_composite_restraint.py @@ -0,0 +1,39 @@ +import IMP +import IMP.test +import IMP.algebra +import IMP.core +import IMP.npc + +class Tests(IMP.test.TestCase): + + def evaluate_config(self, m, particles): + particles_by_type = {} + for particle_data in particles: + name, x, y = particle_data + p = IMP.Particle(m, name) + IMP.core.XYZ.setup_particle(p, IMP.algebra.Vector3D(x,y,0.)) + particle_type = name[0] + if particle_type in particles_by_type: + particles_by_type[particle_type].append(p) + else: + particles_by_type[particle_type] = [p] + print particles_by_type + ps = IMP.core.DistancePairScore(IMP.core.Linear(0.0, 1.0)) + r = IMP.npc.CompositeRestraint(m, ps) + for val in particles_by_type.values(): + r.add_type(val) + return r.evaluate(False) + + def test_bond_parameters(self): + m = IMP.Model() + s = self.evaluate_config(m, + [('A1', 0,0), + ('C1', 1,0), + ('B1', 0,-1), + ('A2', -10,-10), + ('B2', 10,10), + ('C2', 10,-10)]) + print(s) + +if __name__ == '__main__': + IMP.test.main() From 20e4653cc3a8c1d898f7077de7ef64f04722b3a0 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 18 Nov 2015 18:12:20 -0800 Subject: [PATCH 010/491] Initial subset code (not yet correct). --- src/CompositeRestraint.cpp | 94 ++++++++++++++++++++++++++++++-- test/test_composite_restraint.py | 1 + 2 files changed, 91 insertions(+), 4 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index 85d51f1021..d2ed74dc96 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -8,13 +8,24 @@ #include #include #include +#include +#include +#include #include IMPNPC_BEGIN_NAMESPACE namespace { + template void debug_print(std::string caption, const LIST &ls) { + std::cout << caption << " "; + for (typename LIST::const_iterator it = ls.begin(); it != ls.end(); ++it) { + std::cout << *it << " " ; + } + std::cout << std::endl; + } + typedef std::pair TypedParticle; typedef std::vector TypedParticles; @@ -31,6 +42,8 @@ namespace { boost::undirectedS, boost::no_property, boost::property > Graph; + typedef boost::property_map::type + WeightMap; typedef boost::graph_traits::edge_descriptor Edge; typedef Graph::edge_property_type Weight; typedef boost::graph_traits::vertex_descriptor Vertex; @@ -75,16 +88,89 @@ namespace { } } + void add_neighbors(std::set &neighbors, Vertex v, Graph &g, + double max_score) { + WeightMap weight_map = boost::get(boost::edge_weight, g); + boost::graph_traits::out_edge_iterator ei, ei_end; + for (boost::tie(ei, ei_end) = boost::out_edges(v, g); + ei != ei_end; ++ei) { + Vertex t = boost::target(*ei, g); + double weight = weight_map[*ei]; +// std::cout << " consider neighbor " << t << " of " << v << " weight " << weight << std::endl; + if (weight < max_score) { + neighbors.insert(t); + } + } + } + void generate_connected_subgraphs( - std::set vertices_not_yet_considered, - std::vector subset_so_far, std::set neighbors, - Graph &g, std::set &min_vertices, double &min_score) { + std::set &vertices_not_yet_considered, + std::vector &subset_so_far, std::set &neighbors, + Graph &g, std::set &min_vertices, double &min_score, + double max_score) { + /*debug_print >("vertices_not_yet_considered", + vertices_not_yet_considered); + debug_print >("subset_so_far", + subset_so_far); + debug_print >("neighbors", + neighbors);*/ + std::vector candidates; + if (subset_so_far.empty()) { + candidates.insert(candidates.end(), + vertices_not_yet_considered.begin(), + vertices_not_yet_considered.end()); + } else { + std::set_intersection(vertices_not_yet_considered.begin(), + vertices_not_yet_considered.end(), + neighbors.begin(), neighbors.end(), + std::back_inserter(candidates)); + } + /*debug_print >("candidates", + candidates);*/ + if (candidates.empty()) { + std::cout << "found subgraph "; + for (unsigned i = 0; i < subset_so_far.size(); ++i) { + std::cout << subset_so_far[i] << " " ; + } + std::cout << std::endl; + } else { + // Pick one of the candidates at random + boost::uniform_int randint(0, candidates.size() - 1); + unsigned cnum = randint(random_number_generator); +// std::cout << "picked candidate #" << cnum << " = " << candidates[cnum] << std::endl; + std::set new_to_consider; + for (unsigned i = 0; i < candidates.size(); ++i) { + if (i != cnum) { + new_to_consider.insert(candidates[i]); + } + } + generate_connected_subgraphs(new_to_consider, subset_so_far, neighbors, + g, min_vertices, min_score, max_score); + + std::vector new_subset_so_far = subset_so_far; + new_subset_so_far.push_back(candidates[cnum]); + + std::set new_neighbors = neighbors; + add_neighbors(new_neighbors, candidates[cnum], g, max_score); + generate_connected_subgraphs(new_to_consider, new_subset_so_far, + new_neighbors, g, min_vertices, min_score, + max_score); + } } double get_best_scoring_subgraph(Graph &g, double max_score) { double min_score = max_score; std::set min_vertices; - //generate_connected_subgraphs(g, min_vertices, min_score); + std::set vertices_not_yet_considered; + std::vector subset_so_far; + std::set neighbors; + boost::graph_traits::vertex_iterator vi, vi_end; + for (boost::tie(vi, vi_end) = boost::vertices(g); vi != vi_end; ++vi) { + vertices_not_yet_considered.insert(*vi); + } + generate_connected_subgraphs(vertices_not_yet_considered, subset_so_far, + neighbors, g, min_vertices, min_score, + max_score); // score over all edges that connect min_vertices in g } diff --git a/test/test_composite_restraint.py b/test/test_composite_restraint.py index 8039a60bb5..d1f468a443 100644 --- a/test/test_composite_restraint.py +++ b/test/test_composite_restraint.py @@ -20,6 +20,7 @@ def evaluate_config(self, m, particles): print particles_by_type ps = IMP.core.DistancePairScore(IMP.core.Linear(0.0, 1.0)) r = IMP.npc.CompositeRestraint(m, ps) + r.set_maximum_score(10000) for val in particles_by_type.values(): r.add_type(val) return r.evaluate(False) From 352a26088a31854d6a9b94703e8d8ac7a555d9ef Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 19 Nov 2015 14:44:02 -0800 Subject: [PATCH 011/491] Fix update of vertices to consider. --- src/CompositeRestraint.cpp | 8 ++------ test/test_composite_restraint.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index d2ed74dc96..89eae77554 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -138,12 +138,8 @@ namespace { boost::uniform_int randint(0, candidates.size() - 1); unsigned cnum = randint(random_number_generator); // std::cout << "picked candidate #" << cnum << " = " << candidates[cnum] << std::endl; - std::set new_to_consider; - for (unsigned i = 0; i < candidates.size(); ++i) { - if (i != cnum) { - new_to_consider.insert(candidates[i]); - } - } + std::set new_to_consider = vertices_not_yet_considered; + new_to_consider.erase(candidates[cnum]);; generate_connected_subgraphs(new_to_consider, subset_so_far, neighbors, g, min_vertices, min_score, max_score); diff --git a/test/test_composite_restraint.py b/test/test_composite_restraint.py index d1f468a443..a15e815cab 100644 --- a/test/test_composite_restraint.py +++ b/test/test_composite_restraint.py @@ -20,7 +20,7 @@ def evaluate_config(self, m, particles): print particles_by_type ps = IMP.core.DistancePairScore(IMP.core.Linear(0.0, 1.0)) r = IMP.npc.CompositeRestraint(m, ps) - r.set_maximum_score(10000) + r.set_maximum_score(10) for val in particles_by_type.values(): r.add_type(val) return r.evaluate(False) From 4d185263244d18255bb1967da3bb77f2e78a1234 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 19 Nov 2015 23:09:30 -0800 Subject: [PATCH 012/491] Only return subgraphs that contain all particle types. --- src/CompositeRestraint.cpp | 38 +++++++++++++++++++++++--------- test/test_composite_restraint.py | 2 +- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index 89eae77554..ff91755e0e 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -103,10 +103,23 @@ namespace { } } + bool got_all_particle_types(const std::vector &subset_so_far, + const TypedParticles &tps, + int num_particle_types) { + boost::dynamic_bitset<> have_types(num_particle_types); + have_types.set(); + for (std::vector::const_iterator it = subset_so_far.begin(); + it != subset_so_far.end(); ++it) { + have_types.reset(tps[*it].first); + } + return have_types.none(); + } + void generate_connected_subgraphs( std::set &vertices_not_yet_considered, std::vector &subset_so_far, std::set &neighbors, - Graph &g, std::set &min_vertices, double &min_score, + Graph &g, const TypedParticles &tps, int num_particle_types, + std::set &min_vertices, double &min_score, double max_score) { /*debug_print >("vertices_not_yet_considered", vertices_not_yet_considered); @@ -127,13 +140,13 @@ namespace { } /*debug_print >("candidates", candidates);*/ - if (candidates.empty()) { + if (got_all_particle_types(subset_so_far, tps, num_particle_types)) { std::cout << "found subgraph "; for (unsigned i = 0; i < subset_so_far.size(); ++i) { - std::cout << subset_so_far[i] << " " ; + std::cout << tps[subset_so_far[i]].second << " " ; } std::cout << std::endl; - } else { + } else if (!candidates.empty()) { // Pick one of the candidates at random boost::uniform_int randint(0, candidates.size() - 1); unsigned cnum = randint(random_number_generator); @@ -141,7 +154,8 @@ namespace { std::set new_to_consider = vertices_not_yet_considered; new_to_consider.erase(candidates[cnum]);; generate_connected_subgraphs(new_to_consider, subset_so_far, neighbors, - g, min_vertices, min_score, max_score); + g, tps, num_particle_types, min_vertices, + min_score, max_score); std::vector new_subset_so_far = subset_so_far; new_subset_so_far.push_back(candidates[cnum]); @@ -149,12 +163,13 @@ namespace { std::set new_neighbors = neighbors; add_neighbors(new_neighbors, candidates[cnum], g, max_score); generate_connected_subgraphs(new_to_consider, new_subset_so_far, - new_neighbors, g, min_vertices, min_score, - max_score); + new_neighbors, g, tps, num_particle_types, + min_vertices, min_score, max_score); } } - double get_best_scoring_subgraph(Graph &g, double max_score) { + double get_best_scoring_subgraph(Graph &g, const TypedParticles &tps, + int num_particle_types, double max_score) { double min_score = max_score; std::set min_vertices; std::set vertices_not_yet_considered; @@ -165,8 +180,8 @@ namespace { vertices_not_yet_considered.insert(*vi); } generate_connected_subgraphs(vertices_not_yet_considered, subset_so_far, - neighbors, g, min_vertices, min_score, - max_score); + neighbors, g, tps, num_particle_types, + min_vertices, min_score, max_score); // score over all edges that connect min_vertices in g } @@ -178,7 +193,8 @@ double CompositeRestraint::unprotected_evaluate(DerivativeAccumulator *accum) Graph g; compute_mst(get_model(), tps_, ps_, g); show_graph(g, tps_, get_model()); - double score = get_best_scoring_subgraph(g, get_maximum_score()); + double score = get_best_scoring_subgraph(g, tps_, num_particle_types_, + get_maximum_score()); return score; } diff --git a/test/test_composite_restraint.py b/test/test_composite_restraint.py index a15e815cab..6d69a7ff63 100644 --- a/test/test_composite_restraint.py +++ b/test/test_composite_restraint.py @@ -29,8 +29,8 @@ def test_bond_parameters(self): m = IMP.Model() s = self.evaluate_config(m, [('A1', 0,0), - ('C1', 1,0), ('B1', 0,-1), + ('C1', 1,0), ('A2', -10,-10), ('B2', 10,10), ('C2', 10,-10)]) From 50b984f9519dafa349fd8c596d8884468ecde7de Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 12:12:34 -0800 Subject: [PATCH 013/491] Get the score of the best subgraph. --- src/CompositeRestraint.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index ff91755e0e..dfbd9b3bb3 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -115,6 +115,36 @@ namespace { return have_types.none(); } + void update_minimum_subgraph(std::vector &subgraph, + const TypedParticles &tps, Graph &g, + std::set &min_vertices, + double &min_score) { + std::set vertices; + vertices.insert(subgraph.begin(), subgraph.end()); + + // Find the set of edges that connect the subgraph vertices + std::vector edges; + WeightMap weight_map = boost::get(boost::edge_weight, g); + double score = 0.; + boost::graph_traits::edge_iterator ei, ei_end; + for (boost::tie(ei, ei_end) = boost::edges(g); ei != ei_end; ++ei) { + Vertex s = boost::source(*ei, g); + Vertex t = boost::target(*ei, g); + if (vertices.find(s) != vertices.end() + && vertices.find(t) != vertices.end()) { + edges.push_back(*ei); + score += weight_map[*ei]; + if (score >= min_score) { + return; + } + } + } + // The new graph is the best scoring, so update + std::cout << "update minimum scoring subgraph " << score << std::endl; + min_vertices = vertices; + min_score = score; + } + void generate_connected_subgraphs( std::set &vertices_not_yet_considered, std::vector &subset_so_far, std::set &neighbors, @@ -146,6 +176,7 @@ namespace { std::cout << tps[subset_so_far[i]].second << " " ; } std::cout << std::endl; + update_minimum_subgraph(subset_so_far, tps, g, min_vertices, min_score); } else if (!candidates.empty()) { // Pick one of the candidates at random boost::uniform_int randint(0, candidates.size() - 1); @@ -182,7 +213,7 @@ namespace { generate_connected_subgraphs(vertices_not_yet_considered, subset_so_far, neighbors, g, tps, num_particle_types, min_vertices, min_score, max_score); - // score over all edges that connect min_vertices in g + return min_score; } } // anonymous namespace From 197842bec24adb07aaeb57a423069c6abf80b780 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 12:25:53 -0800 Subject: [PATCH 014/491] Provide edges so we can support derivatives. We don't evaluate derivatives when we calculate the fully connected graph (we can't, since we don't end up using each pair score) so if we need derivatives we need to run through the calculated list of edges, and reevaluate each pair score with derivatives. --- src/CompositeRestraint.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index dfbd9b3bb3..427c82a6be 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -117,7 +117,7 @@ namespace { void update_minimum_subgraph(std::vector &subgraph, const TypedParticles &tps, Graph &g, - std::set &min_vertices, + std::vector &min_edges, double &min_score) { std::set vertices; vertices.insert(subgraph.begin(), subgraph.end()); @@ -141,7 +141,7 @@ namespace { } // The new graph is the best scoring, so update std::cout << "update minimum scoring subgraph " << score << std::endl; - min_vertices = vertices; + min_edges = edges; min_score = score; } @@ -149,7 +149,7 @@ namespace { std::set &vertices_not_yet_considered, std::vector &subset_so_far, std::set &neighbors, Graph &g, const TypedParticles &tps, int num_particle_types, - std::set &min_vertices, double &min_score, + std::vector &min_edges, double &min_score, double max_score) { /*debug_print >("vertices_not_yet_considered", vertices_not_yet_considered); @@ -176,7 +176,7 @@ namespace { std::cout << tps[subset_so_far[i]].second << " " ; } std::cout << std::endl; - update_minimum_subgraph(subset_so_far, tps, g, min_vertices, min_score); + update_minimum_subgraph(subset_so_far, tps, g, min_edges, min_score); } else if (!candidates.empty()) { // Pick one of the candidates at random boost::uniform_int randint(0, candidates.size() - 1); @@ -185,7 +185,7 @@ namespace { std::set new_to_consider = vertices_not_yet_considered; new_to_consider.erase(candidates[cnum]);; generate_connected_subgraphs(new_to_consider, subset_so_far, neighbors, - g, tps, num_particle_types, min_vertices, + g, tps, num_particle_types, min_edges, min_score, max_score); std::vector new_subset_so_far = subset_so_far; @@ -195,14 +195,14 @@ namespace { add_neighbors(new_neighbors, candidates[cnum], g, max_score); generate_connected_subgraphs(new_to_consider, new_subset_so_far, new_neighbors, g, tps, num_particle_types, - min_vertices, min_score, max_score); + min_edges, min_score, max_score); } } double get_best_scoring_subgraph(Graph &g, const TypedParticles &tps, - int num_particle_types, double max_score) { + int num_particle_types, double max_score, + std::vector &edges) { double min_score = max_score; - std::set min_vertices; std::set vertices_not_yet_considered; std::vector subset_so_far; std::set neighbors; @@ -212,7 +212,7 @@ namespace { } generate_connected_subgraphs(vertices_not_yet_considered, subset_so_far, neighbors, g, tps, num_particle_types, - min_vertices, min_score, max_score); + edges, min_score, max_score); return min_score; } @@ -224,9 +224,22 @@ double CompositeRestraint::unprotected_evaluate(DerivativeAccumulator *accum) Graph g; compute_mst(get_model(), tps_, ps_, g); show_graph(g, tps_, get_model()); + std::vector edges; double score = get_best_scoring_subgraph(g, tps_, num_particle_types_, - get_maximum_score()); - return score; + get_maximum_score(), edges); + if (accum) { + // Need to reevaluate the score for each edge to get derivatives + ParticleIndexPairs pis(edges.size()); + for (std::vector::const_iterator it = edges.begin(); + it != edges.end(); ++it) { + int i = boost::target(*it, g); + int j = boost::source(*it, g); + pis.push_back(ParticleIndexPair(tps_[i].second, tps_[j].second)); + } + return ps_->evaluate_indexes(get_model(), pis, accum, 0, pis.size()); + } else { + return score; + } } ModelObjectsTemp CompositeRestraint::do_get_inputs() const { From e92bc7ec7f863ed472184c2b2afa29594513f086 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 12:30:14 -0800 Subject: [PATCH 015/491] Remove unused parameter. --- src/CompositeRestraint.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index 427c82a6be..00539ffe93 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -115,8 +115,7 @@ namespace { return have_types.none(); } - void update_minimum_subgraph(std::vector &subgraph, - const TypedParticles &tps, Graph &g, + void update_minimum_subgraph(std::vector &subgraph, Graph &g, std::vector &min_edges, double &min_score) { std::set vertices; @@ -176,7 +175,7 @@ namespace { std::cout << tps[subset_so_far[i]].second << " " ; } std::cout << std::endl; - update_minimum_subgraph(subset_so_far, tps, g, min_edges, min_score); + update_minimum_subgraph(subset_so_far, g, min_edges, min_score); } else if (!candidates.empty()) { // Pick one of the candidates at random boost::uniform_int randint(0, candidates.size() - 1); From 298478689f285a32f51c07f82e324b01c7e413e9 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 12:44:49 -0800 Subject: [PATCH 016/491] Add a method to get the connected particle pairs. --- include/CompositeRestraint.h | 7 +++++++ src/CompositeRestraint.cpp | 34 +++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/include/CompositeRestraint.h b/include/CompositeRestraint.h index c3004c3c30..e0cbb94c5f 100644 --- a/include/CompositeRestraint.h +++ b/include/CompositeRestraint.h @@ -66,6 +66,13 @@ class IMPNPCEXPORT CompositeRestraint : public Restraint { ++num_particle_types_; } + //! Return the set of pairs which are connected by the restraint + /** This set of pairs reflects the current configuration at the time of + the get_connected_pairs() call, not the set at the time of the last + evaluate() call. + */ + ParticleIndexPairs get_connected_pairs() const; + double unprotected_evaluate(DerivativeAccumulator *accum) const IMP_OVERRIDE; ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE; IMP_OBJECT_METHODS(CompositeRestraint); diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index 00539ffe93..c4033be7f8 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -215,6 +215,18 @@ namespace { return min_score; } + void get_particles_from_edges(const std::vector &edges, const Graph &g, + const TypedParticles &tps, + ParticleIndexPairs &pis) { + pis.reserve(edges.size()); + for (std::vector::const_iterator it = edges.begin(); + it != edges.end(); ++it) { + int i = boost::target(*it, g); + int j = boost::source(*it, g); + pis.push_back(ParticleIndexPair(tps[i].second, tps[j].second)); + } + } + } // anonymous namespace double CompositeRestraint::unprotected_evaluate(DerivativeAccumulator *accum) @@ -228,19 +240,27 @@ double CompositeRestraint::unprotected_evaluate(DerivativeAccumulator *accum) get_maximum_score(), edges); if (accum) { // Need to reevaluate the score for each edge to get derivatives - ParticleIndexPairs pis(edges.size()); - for (std::vector::const_iterator it = edges.begin(); - it != edges.end(); ++it) { - int i = boost::target(*it, g); - int j = boost::source(*it, g); - pis.push_back(ParticleIndexPair(tps_[i].second, tps_[j].second)); - } + ParticleIndexPairs pis; + get_particles_from_edges(edges, g, tps_, pis); return ps_->evaluate_indexes(get_model(), pis, accum, 0, pis.size()); } else { return score; } } +ParticleIndexPairs CompositeRestraint::get_connected_pairs() const +{ + IMP_CHECK_OBJECT(ps_.get()); + Graph g; + compute_mst(get_model(), tps_, ps_, g); + std::vector edges; + get_best_scoring_subgraph(g, tps_, num_particle_types_, + get_maximum_score(), edges); + ParticleIndexPairs pis; + get_particles_from_edges(edges, g, tps_, pis); + return pis; +} + ModelObjectsTemp CompositeRestraint::do_get_inputs() const { ModelObjectsTemp ret; ret.reserve(tps_.size()); From 8df6f44577abaa5818d2f1c91fdb28f447bdc23f Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 13:09:14 -0800 Subject: [PATCH 017/491] Add tests of CompositeRestraint. --- test/test_composite_restraint.py | 76 +++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/test/test_composite_restraint.py b/test/test_composite_restraint.py index 6d69a7ff63..2216ac8867 100644 --- a/test/test_composite_restraint.py +++ b/test/test_composite_restraint.py @@ -17,24 +17,90 @@ def evaluate_config(self, m, particles): particles_by_type[particle_type].append(p) else: particles_by_type[particle_type] = [p] - print particles_by_type ps = IMP.core.DistancePairScore(IMP.core.Linear(0.0, 1.0)) r = IMP.npc.CompositeRestraint(m, ps) r.set_maximum_score(10) for val in particles_by_type.values(): r.add_type(val) - return r.evaluate(False) + # Sort pairs so that outputs are consistent for assertions + pairs = r.get_connected_pairs() + pairs = sorted([sorted(p) for p in pairs]) + pairs = [(m.get_particle_name(p[0]), m.get_particle_name(p[1])) + for p in pairs] + return r.evaluate(False), pairs - def test_bond_parameters(self): + def test_composite_restraint_subset(self): + """Make sure CompositeRestraint finds the right subset""" m = IMP.Model() - s = self.evaluate_config(m, + # A2, B2, C2 should be pruned since they are far away, B1-A1-C1 returned + score, pairs = self.evaluate_config(m, [('A1', 0,0), ('B1', 0,-1), ('C1', 1,0), ('A2', -10,-10), ('B2', 10,10), ('C2', 10,-10)]) - print(s) + self.assertAlmostEqual(score, 2.0, delta=1e-6) + self.assertEqual(pairs, [('A1', 'B1'), ('A1', 'C1')]) + + def test_composite_restraint_simple(self): + """Check CompositeRestraint with simple systems, no copies""" + m = IMP.Model() + score, pairs = self.evaluate_config(m, + [('A1', 0,0), + ('B1', 1,0), + ('C1', 2,0)]) + self.assertAlmostEqual(score, 2.0, delta=1e-6) + self.assertEqual(pairs, [('A1', 'B1'), ('B1', 'C1')]) + + def test_composite_restraint_multiple(self): + """Multiple copies of a particle should be OK""" + m = IMP.Model() + score, pairs = self.evaluate_config(m, + [('A1', 0,0), + ('B1', 1,0), + ('B2', 2,0), + ('C1', 3,0)]) + self.assertAlmostEqual(score, 3.0, delta=1e-6) + self.assertEqual(pairs, [('A1', 'B1'), ('B1', 'B2'), ('B2', 'C1')]) + + def test_composite_restraint_minimum(self): + """Make sure minimum subtree is returned""" + m = IMP.Model() + # Two possible subtrees: A1-B1-B2-C1 and C1-B3-A2; make sure we find + # the lower scoring one + score, pairs = self.evaluate_config(m, + [('A1', 0,0), + ('B1', 1,0), + ('B2', 2,0), + ('C1', 3,0), + ('B3', 4,0), + ('A2', 5,0)]) + self.assertAlmostEqual(score, 2.0, delta=1e-6) + self.assertEqual(pairs, [('C1', 'B3'), ('B3', 'A2')]) + + def test_composite_restraint_exceed_max_score_multiple(self): + """Check handling of multiple copies with an edge above max_score""" + m = IMP.Model() + # We have OK A-B and B-C interactions, but the B-B distance is too large + score, pairs = self.evaluate_config(m, + [('A1', 0,0), + ('B1', 1,0), + ('B2', 30,0), + ('C1', 31,0)]) + self.assertAlmostEqual(score, 10.0, delta=1e-6) + self.assertEqual(pairs, []) + + def test_composite_restraint_exceed_max_score(self): + """Check failure with an edge above max_score""" + m = IMP.Model() + # Composite cannot be satisfied + score, pairs = self.evaluate_config(m, + [('A1', 0,0), + ('B1', 1,0), + ('C1', 31,0)]) + self.assertAlmostEqual(score, 10.0, delta=1e-6) + self.assertEqual(pairs, []) if __name__ == '__main__': IMP.test.main() From e68ea4e4b2ef163bf1d77ad5e3d0cb87b02867da Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 13:09:51 -0800 Subject: [PATCH 018/491] Remove debug prints. --- src/CompositeRestraint.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index c4033be7f8..e5ffed610f 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -18,14 +18,6 @@ IMPNPC_BEGIN_NAMESPACE namespace { - template void debug_print(std::string caption, const LIST &ls) { - std::cout << caption << " "; - for (typename LIST::const_iterator it = ls.begin(); it != ls.end(); ++it) { - std::cout << *it << " " ; - } - std::cout << std::endl; - } - typedef std::pair TypedParticle; typedef std::vector TypedParticles; @@ -150,12 +142,6 @@ namespace { Graph &g, const TypedParticles &tps, int num_particle_types, std::vector &min_edges, double &min_score, double max_score) { - /*debug_print >("vertices_not_yet_considered", - vertices_not_yet_considered); - debug_print >("subset_so_far", - subset_so_far); - debug_print >("neighbors", - neighbors);*/ std::vector candidates; if (subset_so_far.empty()) { candidates.insert(candidates.end(), @@ -167,8 +153,6 @@ namespace { neighbors.begin(), neighbors.end(), std::back_inserter(candidates)); } - /*debug_print >("candidates", - candidates);*/ if (got_all_particle_types(subset_so_far, tps, num_particle_types)) { std::cout << "found subgraph "; for (unsigned i = 0; i < subset_so_far.size(); ++i) { From d395ceabb23d4b27b1db605c0a614c2c82c5c623 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 13:10:37 -0800 Subject: [PATCH 019/491] Remove debugging prints. --- src/CompositeRestraint.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index e5ffed610f..abf2fadaaf 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -40,20 +40,6 @@ namespace { typedef Graph::edge_property_type Weight; typedef boost::graph_traits::vertex_descriptor Vertex; - /* debugging */ - void show_graph(const Graph &g, const TypedParticles &tps, Model *m) { - std::cout << boost::num_vertices(g) << " vertices" << std::endl; - std::cout << boost::num_edges(g) << " edges = "; - boost::graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = boost::edges(g); ei != ei_end; ++ei) { - int s = boost::source(*ei, g); - int t = boost::target(*ei, g); - std::cout << "(" << m->get_particle_name(tps[s].second) - << "," << m->get_particle_name(tps[t].second) << ") "; - } - std::cout << std::endl; - } - void compute_mst(Model *m, const TypedParticles &tps, PairScore *ps, Graph &g) { // Create fully connected graph @@ -218,7 +204,6 @@ double CompositeRestraint::unprotected_evaluate(DerivativeAccumulator *accum) IMP_CHECK_OBJECT(ps_.get()); Graph g; compute_mst(get_model(), tps_, ps_, g); - show_graph(g, tps_, get_model()); std::vector edges; double score = get_best_scoring_subgraph(g, tps_, num_particle_types_, get_maximum_score(), edges); From 3c71131b00997ac7ca484d854bd452f0d11b94dc Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 13:11:01 -0800 Subject: [PATCH 020/491] Remove debugging prints. --- src/CompositeRestraint.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index abf2fadaaf..ffdefa694d 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -49,7 +49,6 @@ namespace { double d = ps->evaluate_index(m, ParticleIndexPair(tps[i].second, tps[j].second), nullptr); -// std::cout << "add edge " << i << "," << j << " => " << d << std::endl; boost::add_edge(i, j, d, full_g); } } @@ -60,7 +59,6 @@ namespace { FullGraphWeightMap weight_map = boost::get(boost::edge_weight, full_g); for (std::vector::const_iterator it = mst.begin(); it != mst.end(); ++it) { -// std::cout << boost::source(*it, full_g) << " " << boost::target(*it, full_g) << " " << weight_map[*it] << std::endl; boost::add_edge(boost::source(*it, full_g), boost::target(*it, full_g), weight_map[*it], g); } @@ -74,7 +72,6 @@ namespace { ei != ei_end; ++ei) { Vertex t = boost::target(*ei, g); double weight = weight_map[*ei]; -// std::cout << " consider neighbor " << t << " of " << v << " weight " << weight << std::endl; if (weight < max_score) { neighbors.insert(t); } @@ -150,7 +147,6 @@ namespace { // Pick one of the candidates at random boost::uniform_int randint(0, candidates.size() - 1); unsigned cnum = randint(random_number_generator); -// std::cout << "picked candidate #" << cnum << " = " << candidates[cnum] << std::endl; std::set new_to_consider = vertices_not_yet_considered; new_to_consider.erase(candidates[cnum]);; generate_connected_subgraphs(new_to_consider, subset_so_far, neighbors, From 73e2054e10ec057652f3a5ce72ab913af23679e4 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 20 Nov 2015 13:20:09 -0800 Subject: [PATCH 021/491] Replace debug prints with logging. --- src/CompositeRestraint.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index ffdefa694d..c5608bb70e 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -114,7 +114,6 @@ namespace { } } // The new graph is the best scoring, so update - std::cout << "update minimum scoring subgraph " << score << std::endl; min_edges = edges; min_score = score; } @@ -137,11 +136,6 @@ namespace { std::back_inserter(candidates)); } if (got_all_particle_types(subset_so_far, tps, num_particle_types)) { - std::cout << "found subgraph "; - for (unsigned i = 0; i < subset_so_far.size(); ++i) { - std::cout << tps[subset_so_far[i]].second << " " ; - } - std::cout << std::endl; update_minimum_subgraph(subset_so_far, g, min_edges, min_score); } else if (!candidates.empty()) { // Pick one of the candidates at random @@ -203,6 +197,18 @@ double CompositeRestraint::unprotected_evaluate(DerivativeAccumulator *accum) std::vector edges; double score = get_best_scoring_subgraph(g, tps_, num_particle_types_, get_maximum_score(), edges); + IMP_IF_LOG(VERBOSE) { + ParticleIndexPairs pis; + get_particles_from_edges(edges, g, tps_, pis); + IMP_LOG_VERBOSE("Minimum subtree is ["); + for (ParticleIndexPairs::const_iterator it = pis.begin(); it != pis.end(); + ++it) { + IMP_LOG_VERBOSE("(" << get_model()->get_particle_name((*it)[0]) + << ", " << get_model()->get_particle_name((*it)[1]) + << ") "); + } + IMP_LOG_VERBOSE("]" << std::endl); + } if (accum) { // Need to reevaluate the score for each edge to get derivatives ParticleIndexPairs pis; From 6b2b8bf957c1255c95febcf2e49de154e1a89169 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Sat, 21 Nov 2015 11:55:31 -0800 Subject: [PATCH 022/491] Add cast for older Boosts. --- src/CompositeRestraint.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index c5608bb70e..5f17b6983c 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -28,6 +28,7 @@ namespace { typedef boost::property_map::type FullGraphWeightMap; typedef boost::graph_traits::edge_descriptor FullGraphEdge; + typedef FullGraph::edge_property_type FullGraphWeight; /* Graph type used for MST */ typedef boost::adjacency_listevaluate_index(m, ParticleIndexPair(tps[i].second, tps[j].second), nullptr); - boost::add_edge(i, j, d, full_g); + boost::add_edge(i, j, static_cast(d), full_g); } } std::vector mst; From 6318c759bdd093d7d70605433f985e338bb933b0 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 2 Dec 2015 14:35:45 -0800 Subject: [PATCH 023/491] Add a MinimumSphereDistancePairScore. This acts like a regular SphereDistancePairScore but considers one or more transformations of one particle in an attempt to decrease the pairwise distance (for handling symmetry). --- include/MinimumSphereDistancePairScore.h | 50 ++++++++++++++++++++++++ pyext/swig.i-in | 2 + src/MinimumSphereDistancePairScore.cpp | 47 ++++++++++++++++++++++ test/test_min_pair_score.py | 46 ++++++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 include/MinimumSphereDistancePairScore.h create mode 100644 src/MinimumSphereDistancePairScore.cpp create mode 100644 test/test_min_pair_score.py diff --git a/include/MinimumSphereDistancePairScore.h b/include/MinimumSphereDistancePairScore.h new file mode 100644 index 0000000000..7ece1170da --- /dev/null +++ b/include/MinimumSphereDistancePairScore.h @@ -0,0 +1,50 @@ +/** + * \file IMP/npc/MinimumSphereDistancePairScore.h + * \brief Apply a UnaryFunction to the minimum transformed distance + * + * Copyright 2007-2015 IMP Inventors. All rights reserved. + */ + +#ifndef IMPNPC_MINIMUM_SPHERE_DISTANCE_PAIR_SCORE_H +#define IMPNPC_MINIMUM_SPHERE_DISTANCE_PAIR_SCORE_H + +#include +#include +#include +#include +#include + +IMPNPC_BEGIN_NAMESPACE + +//! Apply a UnaryFunction to the minimum transformed sphere-sphere distance +/** This is like a SphereDistancePairScore in that it calculates the + inter-surface distance between two XYZR Particles (spheres) and then + scores it with a provided UnaryFunction. However, it also considers + the distance between the two particles with the second particle + transformed by each of the provided transformations. The transformation + which results in the minimum interparticle distance (not necessarily the + minimum score) is then used for scoring. This can be used for periodic + boundaries or other symmetric systems. + */ +class MinimumSphereDistancePairScore : public PairScore { + IMP::PointerMember f_; + algebra::Transformation3Ds transforms_; + + public: + MinimumSphereDistancePairScore(UnaryFunction *f, + algebra::Transformation3Ds transforms) + : f_(f), transforms_(transforms) {} + + virtual double evaluate_index(Model *m, const ParticleIndexPair &pi, + DerivativeAccumulator *da) const IMP_OVERRIDE; + virtual ModelObjectsTemp do_get_inputs( + Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE { + return IMP::get_particles(m, pis); + } + IMP_PAIR_SCORE_METHODS(MinimumSphereDistancePairScore); + IMP_OBJECT_METHODS(MinimumSphereDistancePairScore); +}; + +IMPNPC_END_NAMESPACE + +#endif /* IMPNPC_MINIMUM_SPHERE_DISTANCE_PAIR_SCORE_H */ diff --git a/pyext/swig.i-in b/pyext/swig.i-in index 4625125244..1771cf7b63 100644 --- a/pyext/swig.i-in +++ b/pyext/swig.i-in @@ -11,6 +11,8 @@ IMP_SWIG_OBJECT( IMP::npc, AssemblySymmetryByDistanceRestraint, AssemblySymmetry IMP_SWIG_OBJECT( IMP::npc, AssemblySymmetryByDihedralRestraint, AssemblySymmetryByDihedralRestraints); IMP_SWIG_OBJECT( IMP::npc, ProteinProximityRestraint, ProteinProximityRestraints); IMP_SWIG_OBJECT( IMP::npc, CompositeRestraint, CompositeRestraints); +IMP_SWIG_OBJECT( IMP::npc, MinimumSphereDistancePairScore, MinimumSphereDistancePairScores); %include "IMP/npc/ProteinLocalizationRestraint.h" %include "IMP/npc/CompositeRestraint.h" +%include "IMP/npc/MinimumSphereDistancePairScore.h" diff --git a/src/MinimumSphereDistancePairScore.cpp b/src/MinimumSphereDistancePairScore.cpp new file mode 100644 index 0000000000..f4b755d603 --- /dev/null +++ b/src/MinimumSphereDistancePairScore.cpp @@ -0,0 +1,47 @@ +/** + * \file MinimumSphereDistancePairScore.cpp + * \brief Apply a UnaryFunction to the minimum transformed distance + * + * Copyright 2007-2015 IMP Inventors. All rights reserved. + */ + +#include +#include +#include +#include +#include + +IMPNPC_BEGIN_NAMESPACE + +double MinimumSphereDistancePairScore::evaluate_index(Model *m, + const ParticleIndexPair &pi, + DerivativeAccumulator *da) const { + core::XYZR d0(m, pi[0]); + core::XYZR d1(m, pi[1]); + algebra::Vector3D c0 = d0.get_coordinates(); + algebra::Vector3D c1_orig = d1.get_coordinates(), c1_min = c1_orig; + double dist2_min = algebra::get_squared_distance(c0, c1_orig); + + /* Find transformation that gives the minimum pairwise distance */ + for (algebra::Transformation3Ds::const_iterator it = transforms_.begin(); + it != transforms_.end(); ++it) { + algebra::Vector3D c1_transformed = (*it) * c1_orig; + double dist2 = algebra::get_squared_distance(c0, c1_transformed); + if (dist2 < dist2_min) { + c1_min = c1_transformed; + dist2_min = dist2; + } + } + + algebra::Vector3D d; + double v = core::internal::compute_distance_pair_score(c0 - c1_min, f_.get(), + da ? &d : nullptr, + boost::lambda::_1 - d0.get_radius() - d1.get_radius()); + if (da) { + d0.add_to_derivatives(d, *da); + d1.add_to_derivatives(-d, *da); + } + return v; +} + +IMPNPC_END_NAMESPACE diff --git a/test/test_min_pair_score.py b/test/test_min_pair_score.py new file mode 100644 index 0000000000..05f44763b5 --- /dev/null +++ b/test/test_min_pair_score.py @@ -0,0 +1,46 @@ +import IMP +import IMP.test +import IMP.algebra +import IMP.core +import IMP.npc + +class Tests(IMP.test.TestCase): + + def get_score(self, m, transforms): + p0 = IMP.Particle(m, "p0") + IMP.core.XYZR.setup_particle(p0, IMP.algebra.Sphere3D( + IMP.algebra.Vector3D(2,0,0.), 0.4)) + p1 = IMP.Particle(m, "p1") + IMP.core.XYZR.setup_particle(p1, IMP.algebra.Sphere3D( + IMP.algebra.Vector3D(9,0,0.), 0.1)) + + ps = IMP.npc.MinimumSphereDistancePairScore(IMP.core.Linear(0.0, 1.0), + transforms) + r = IMP.core.PairRestraint(m, ps, [p0,p1]) + return r.evaluate(True) + + def test_no_transform(self): + """Test pair score with no transforms""" + m = IMP.Model() + # Should return the regular sphere distance + self.assertAlmostEqual(self.get_score(m, []), 6.5, delta=1e-6) + + def test_min_transform(self): + """Test pair score with a transform that reduces the distance""" + m = IMP.Model() + transforms = [IMP.algebra.Transformation3D( + IMP.algebra.get_identity_rotation_3d(), + IMP.algebra.Vector3D(-10,0,0))] + # This transform should move p1 to be closer to p0 + self.assertAlmostEqual(self.get_score(m, transforms), 2.5, delta=1e-6) + + def test_bad_transform(self): + """Test pair score with a transform that doesn't reduce the distance""" + m = IMP.Model() + transforms = [IMP.algebra.Transformation3D( + IMP.algebra.get_identity_rotation_3d(), + IMP.algebra.Vector3D(10,0,0))] + self.assertAlmostEqual(self.get_score(m, transforms), 6.5, delta=1e-6) + +if __name__ == '__main__': + IMP.test.main() From 7dba31b5381c230cc72c80b0e1e6a10d6f4615fb Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 3 Dec 2015 10:05:10 -0800 Subject: [PATCH 024/491] Add missing export. --- include/MinimumSphereDistancePairScore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/MinimumSphereDistancePairScore.h b/include/MinimumSphereDistancePairScore.h index 7ece1170da..ec29e92ab1 100644 --- a/include/MinimumSphereDistancePairScore.h +++ b/include/MinimumSphereDistancePairScore.h @@ -26,7 +26,7 @@ IMPNPC_BEGIN_NAMESPACE minimum score) is then used for scoring. This can be used for periodic boundaries or other symmetric systems. */ -class MinimumSphereDistancePairScore : public PairScore { +class IMPNPCEXPORT MinimumSphereDistancePairScore : public PairScore { IMP::PointerMember f_; algebra::Transformation3Ds transforms_; From 150f2fe8cd40fbc67bf0021a5623e5cb4286a897 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Wed, 18 May 2016 23:22:29 -0700 Subject: [PATCH 025/491] add npc_restraints.py --- pyext/src/npc_restraints.py | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 pyext/src/npc_restraints.py diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py new file mode 100644 index 0000000000..2c02cc245b --- /dev/null +++ b/pyext/src/npc_restraints.py @@ -0,0 +1,59 @@ +import IMP.npc + +class XYRadialPositionLowerRestraint(object): + """Create XYRadial Position Lower restraints + """ + def __init__(self, + representation = None, + protein = None, + lower_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("XYRadialPositionLowerRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'XYRadialPositionLowerRestraint') + self.weight=1.0 + self.label = "None" + + xyr = IMP.npc.XYRadialPositionLowerRestraint(self.m, lower_bound, consider_radius, sigma) + terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + print (terminal_residue, type(terminal_residue)) + + xyr.add_particle(terminal_residue) + xyr.set_name('Radial_Position_Lower_%s_%d' % (protein, lower_bound)) + self.rs.add_restraint(xyr) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["XYRadialPositionLowerRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) From 40f1764e9777a0ee01b0af74271d52f870142dde Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Thu, 19 May 2016 00:20:31 -0700 Subject: [PATCH 026/491] added XYRadialPositionUpperRestraint, nZAxialPositionLowerRestraint, and ZAxialPositionUpperRestraint --- pyext/src/npc_restraints.py | 176 +++++++++++++++++++++++++++++++++++- 1 file changed, 174 insertions(+), 2 deletions(-) diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index 2c02cc245b..fe4e38facc 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -1,5 +1,6 @@ import IMP.npc + class XYRadialPositionLowerRestraint(object): """Create XYRadial Position Lower restraints """ @@ -28,10 +29,9 @@ def __init__(self, xyr = IMP.npc.XYRadialPositionLowerRestraint(self.m, lower_bound, consider_radius, sigma) terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") - print (terminal_residue, type(terminal_residue)) + #print (terminal_residue, type(terminal_residue)) xyr.add_particle(terminal_residue) - xyr.set_name('Radial_Position_Lower_%s_%d' % (protein, lower_bound)) self.rs.add_restraint(xyr) def set_label(self, label): @@ -57,3 +57,175 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) + + +class XYRadialPositionUpperRestraint(object): + """Create XYRadial Position Upper restraints + """ + def __init__(self, + representation = None, + protein = None, + upper_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("XYRadialPositionUpperRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'XYRadialPositionUpperRestraint') + self.weight=1.0 + self.label = "None" + + xyr = IMP.npc.XYRadialPositionUpperRestraint(self.m, upper_bound, consider_radius, sigma) + terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + #print (terminal_residue, type(terminal_residue)) + + xyr.add_particle(terminal_residue) + self.rs.add_restraint(xyr) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["XYRadialPositionUpperRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + +class ZAxialPositionLowerRestraint(object): + """Create Z-Axial Position Lower restraints + """ + def __init__(self, + representation = None, + protein = None, + lower_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("ZAxialPositionLowerRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'ZAxialPositionLowerRestraint') + self.weight=1.0 + self.label = "None" + + zax = IMP.npc.ZAxialPositionLowerRestraint(self.m, lower_bound, consider_radius, sigma) + terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + #print (terminal_residue, type(terminal_residue)) + + zax.add_particle(terminal_residue) + self.rs.add_restraint(zax) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["ZAxialPositionLowerRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + +class ZAxialPositionUpperRestraint(object): + """Create Z-Axial Position Upper restraints + """ + def __init__(self, + representation = None, + protein = None, + upper_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("ZAxialPositionUpperRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'ZAxialPositionUpperRestraint') + self.weight=1.0 + self.label = "None" + + zax = IMP.npc.ZAxialPositionUpperRestraint(self.m, upper_bound, consider_radius, sigma) + terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + #print (terminal_residue, type(terminal_residue)) + + zax.add_particle(terminal_residue) + self.rs.add_restraint(zax) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["ZAxialPositionUpperRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) From 30029ca0eb91c1a7494536d2f888d87a5513c4e4 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Sun, 29 May 2016 06:38:17 -0700 Subject: [PATCH 027/491] add membranes / cytoplasm / nucloplasm nups and fix a bug selecting a C-terminus for immuno-EM --- pyext/src/npc_restraints.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index fe4e38facc..f65c166ebb 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -28,10 +28,12 @@ def __init__(self, self.label = "None" xyr = IMP.npc.XYRadialPositionLowerRestraint(self.m, lower_bound, consider_radius, sigma) - terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") - #print (terminal_residue, type(terminal_residue)) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) - xyr.add_particle(terminal_residue) + xyr.add_particle(cterminal) self.rs.add_restraint(xyr) def set_label(self, label): @@ -86,10 +88,12 @@ def __init__(self, self.label = "None" xyr = IMP.npc.XYRadialPositionUpperRestraint(self.m, upper_bound, consider_radius, sigma) - terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") - #print (terminal_residue, type(terminal_residue)) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) - xyr.add_particle(terminal_residue) + xyr.add_particle(cterminal) self.rs.add_restraint(xyr) def set_label(self, label): @@ -143,10 +147,12 @@ def __init__(self, self.label = "None" zax = IMP.npc.ZAxialPositionLowerRestraint(self.m, lower_bound, consider_radius, sigma) - terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") - #print (terminal_residue, type(terminal_residue)) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) - zax.add_particle(terminal_residue) + zax.add_particle(cterminal) self.rs.add_restraint(zax) def set_label(self, label): @@ -200,10 +206,12 @@ def __init__(self, self.label = "None" zax = IMP.npc.ZAxialPositionUpperRestraint(self.m, upper_bound, consider_radius, sigma) - terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") - #print (terminal_residue, type(terminal_residue)) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) - zax.add_particle(terminal_residue) + zax.add_particle(cterminal) self.rs.add_restraint(zax) def set_label(self, label): From d2a79e72a9a428969c05c59093a0e1122c8cd09f Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Wed, 1 Jun 2016 16:48:01 -0700 Subject: [PATCH 028/491] improve performance of the immuno-EM restraints --- include/ProteinLocalizationRestraint.h | 84 ++++- pyext/src/npc_restraints.py | 121 +++++++ src/ProteinLocalizationRestraint.cpp | 459 ++++++++++++++++++------- 3 files changed, 521 insertions(+), 143 deletions(-) diff --git a/include/ProteinLocalizationRestraint.h b/include/ProteinLocalizationRestraint.h index 3a76e94264..5da669b9d6 100644 --- a/include/ProteinLocalizationRestraint.h +++ b/include/ProteinLocalizationRestraint.h @@ -19,6 +19,31 @@ IMPNPC_BEGIN_NAMESPACE +class IMPNPCEXPORT ZAxialPositionRestraint : public Restraint +{ + IMP::PointerMember sc_; + double lower_bound_; + double upper_bound_; + double sigma_; + bool consider_radius_; +public: + ZAxialPositionRestraint(Model *m, SingletonContainerAdaptor sc, + double lower_bound, double upper_bound, bool consider_radius, double sigma=1); + ZAxialPositionRestraint(Model *m, + double lower_bound, double upper_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(ZAxialPositionRestraint);; +}; + class IMPNPCEXPORT ZAxialPositionLowerRestraint : public Restraint { IMP::PointerMember sc_; @@ -43,18 +68,17 @@ class IMPNPCEXPORT ZAxialPositionLowerRestraint : public Restraint IMP_OBJECT_METHODS(ZAxialPositionLowerRestraint);; }; - -class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint +class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint { IMP::PointerMember sc_; - double lower_bound_; + double upper_bound_; double sigma_; bool consider_radius_; public: - XYRadialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, - double lower_bound, bool consider_radius, double sigma=1); - XYRadialPositionLowerRestraint(Model *m, - double lower_bound, bool consider_radius, double sigma=1); + ZAxialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, + double upper_bound, bool consider_radius, double sigma=1); + ZAxialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma=1); #ifndef IMP_DOXYGEN void add_particle(Particle *p); @@ -65,21 +89,22 @@ class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; ModelObjectsTemp do_get_inputs() const; - IMP_OBJECT_METHODS(XYRadialPositionLowerRestraint);; + IMP_OBJECT_METHODS(ZAxialPositionUpperRestraint);; }; -class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint +class IMPNPCEXPORT XYRadialPositionRestraint : public Restraint { IMP::PointerMember sc_; + double lower_bound_; double upper_bound_; double sigma_; bool consider_radius_; public: - XYRadialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, - double upper_bound, bool consider_radius, double sigma=1); - XYRadialPositionUpperRestraint(Model *m, - double upper_bound, bool consider_radius, double sigma=1); + XYRadialPositionRestraint(Model *m, SingletonContainerAdaptor sc, + double lower_bound, double upper_bound, bool consider_radius, double sigma=1); + XYRadialPositionRestraint(Model *m, + double lower_bound, double upper_bound, bool consider_radius, double sigma=1); #ifndef IMP_DOXYGEN void add_particle(Particle *p); @@ -90,20 +115,43 @@ class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; ModelObjectsTemp do_get_inputs() const; - IMP_OBJECT_METHODS(XYRadialPositionUpperRestraint);; + IMP_OBJECT_METHODS(XYRadialPositionRestraint);; }; +class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint +{ + IMP::PointerMember sc_; + double lower_bound_; + double sigma_; + bool consider_radius_; +public: + XYRadialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, + double lower_bound, bool consider_radius, double sigma=1); + XYRadialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma=1); -class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(XYRadialPositionLowerRestraint);; +}; + +class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint { IMP::PointerMember sc_; double upper_bound_; double sigma_; bool consider_radius_; public: - ZAxialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, + XYRadialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, double upper_bound, bool consider_radius, double sigma=1); - ZAxialPositionUpperRestraint(Model *m, + XYRadialPositionUpperRestraint(Model *m, double upper_bound, bool consider_radius, double sigma=1); #ifndef IMP_DOXYGEN @@ -115,7 +163,7 @@ class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; ModelObjectsTemp do_get_inputs() const; - IMP_OBJECT_METHODS(ZAxialPositionUpperRestraint);; + IMP_OBJECT_METHODS(XYRadialPositionUpperRestraint);; }; diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index f65c166ebb..e8a3af3e37 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -1,6 +1,67 @@ import IMP.npc +class XYRadialPositionRestraint(object): + """Create XYRadial Position Lower restraints + """ + def __init__(self, + representation = None, + protein = None, + lower_bound = 0.0, + upper_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("XYRadialPositionRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'XYRadialPositionRestraint') + self.weight=1.0 + self.label = "None" + + xyr = IMP.npc.XYRadialPositionRestraint(self.m, lower_bound, upper_bound, consider_radius, sigma) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) + + xyr.add_particle(cterminal) + self.rs.add_restraint(xyr) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["XYRadialPositionRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + + class XYRadialPositionLowerRestraint(object): """Create XYRadial Position Lower restraints """ @@ -120,6 +181,66 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) +class ZAxialPositionRestraint(object): + """Create Z-Axial Position restraints + """ + def __init__(self, + representation = None, + protein = None, + lower_bound = 0.0, + upper_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("ZAxialPositionRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'ZAxialPositionRestraint') + self.weight=1.0 + self.label = "None" + + zax = IMP.npc.ZAxialPositionRestraint(self.m, lower_bound, upper_bound, consider_radius, sigma) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) + + zax.add_particle(cterminal) + self.rs.add_restraint(zax) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["ZAxialPositionRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + class ZAxialPositionLowerRestraint(object): """Create Z-Axial Position Lower restraints """ diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index d58fdc660d..9777ac0c2d 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -37,6 +37,112 @@ IMP::internal::StaticListContainer *get_list( } } +/*##################################################### +# Restraints setup - Immuno-EM ZAxialPositionRestraint +# Supplementary Table 7. Upper and lower bounds on Z-axial restraints of C-terminal bead of nups +# NupType : (min Z value, max Z value) (in Angstrom) +#####################################################*/ +ZAxialPositionRestraint::ZAxialPositionRestraint(Model *m, + SingletonContainerAdaptor sc, + double lower_bound, double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionRestraint %1%") + , lower_bound_(lower_bound) + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + +ZAxialPositionRestraint::ZAxialPositionRestraint(Model *m, + double lower_bound, double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionRestraint %1%") + , lower_bound_(lower_bound) + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + +void ZAxialPositionRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void ZAxialPositionRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void ZAxialPositionRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +double +ZAxialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0.0; + IMP::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i=0; i < all_particles.size(); ++i ) + { + double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0.0; + double z = core::XYZR(all_particles[i]).get_coordinate(2); + double z_down = consider_radius_ ? z - r : z; + double z_up = consider_radius_ ? z + r : z; + double z_diff = z_down - lower_bound_; + // check lower_bound_ + if ( z_diff < 0 ) + { + v += z_diff*z_diff; + if ( accum ) + { + algebra::Vector3D dz; + dz[0] = dz[1] = 0.0; + dz[2] = 2.0*z_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + // check upper_bound_ + z_diff = z_up - upper_bound_; + if ( z_diff > 0 ) + { + v += z_diff*z_diff; + if ( accum ) + { + algebra::Vector3D dz; + dz[0] = dz[1] = 0.0; + dz[2] = 2.0*z_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + } + return v/sigma_; +} + +ModelObjectsTemp ZAxialPositionRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + +/*##################################################### +# Restraints setup - Immuno-EM ZAxialPositionLowerRestraint +# Supplementary Table 7. Upper and lower bounds on Z-axial restraints of C-terminal bead of nups +# NupType : (min Z value, max Z value) (in Angstrom) +#####################################################*/ ZAxialPositionLowerRestraint::ZAxialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, double lower_bound, bool consider_radius, double sigma) @@ -48,7 +154,6 @@ ZAxialPositionLowerRestraint::ZAxialPositionLowerRestraint(Model *m, sc_ = sc; } - ZAxialPositionLowerRestraint::ZAxialPositionLowerRestraint(Model *m, double lower_bound, bool consider_radius, double sigma) : Restraint(m, "ZAxialPositionLowerRestraint %1%") @@ -58,7 +163,6 @@ ZAxialPositionLowerRestraint::ZAxialPositionLowerRestraint(Model *m, { } - void ZAxialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -83,7 +187,6 @@ void ZAxialPositionLowerRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double ZAxialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -111,7 +214,6 @@ ZAxialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) return v/sigma_; } - ModelObjectsTemp ZAxialPositionLowerRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); @@ -120,85 +222,198 @@ ModelObjectsTemp ZAxialPositionLowerRestraint::do_get_inputs() const { } - -XYRadialPositionLowerRestraint::XYRadialPositionLowerRestraint(Model *m, +/*##################################################### +# Restraints setup - Immuno-EM ZAxialPositionUpperRestraint +# Supplementary Table 7. Upper and lower bounds on Z-axial restraints of C-terminal bead of nups +# NupType : (min Z value, max Z value) (in Angstrom) +#####################################################*/ +ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, - double lower_bound, bool consider_radius, double sigma) - : Restraint(m, "XYRadialPositionLowerRestraint %1%") - , lower_bound_(lower_bound) + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) , sigma_(sigma) , consider_radius_(consider_radius) { sc_ = sc; } +ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "ZAxialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} -XYRadialPositionLowerRestraint::XYRadialPositionLowerRestraint(Model *m, - double lower_bound, bool consider_radius, double sigma) - : Restraint(m, "XYRadialPositionLowerRestraint %1%") +void ZAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void ZAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void ZAxialPositionUpperRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Z axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +double +ZAxialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0; + double z = core::XYZR(all_particles[i]).get_coordinate(2); + double z_up = z + r; + double z_diff = z_up - upper_bound_; + if ( z_diff > 0 ) + { + v += z_diff*z_diff; + if ( accum ) + { + algebra::Vector3D dz; + dz[0] = dz[1] = 0; + dz[2] = 2*z_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + } + return v/sigma_; +} + +ModelObjectsTemp ZAxialPositionUpperRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + +/*##################################################### +# Restraints setup - Immuno-EM XYRadialPositionRestraint +# Supplementary Table 7. Upper and lower bounds on R-radial restraints of C-terminal bead of nups +# NupType : (min R value, max R value) (in Angstrom) +#####################################################*/ +XYRadialPositionRestraint::XYRadialPositionRestraint(Model *m, + SingletonContainerAdaptor sc, + double lower_bound, double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionRestraint %1%") , lower_bound_(lower_bound) + , upper_bound_(upper_bound) , sigma_(sigma) , consider_radius_(consider_radius) { + sc_ = sc; } +XYRadialPositionRestraint::XYRadialPositionRestraint(Model *m, + double lower_bound, double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionRestraint %1%") + , lower_bound_(lower_bound) + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} -void XYRadialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { +void XYRadialPositionRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( - ps[0]->get_model(), "XY radial list"); + ps[0]->get_model(), "XY Radial list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); } -void XYRadialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { +void XYRadialPositionRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( - ps[0]->get_model(), "XY radial list"); + ps[0]->get_model(), "XY Radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); } -void XYRadialPositionLowerRestraint::add_particle(Particle *ps) { +void XYRadialPositionRestraint::add_particle(Particle *ps) { if (!sc_) { sc_ = new IMP::internal::StaticListContainer( - ps->get_model(), "XY radial list"); + ps->get_model(), "XY Radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); } - double -XYRadialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +XYRadialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); const double eps = 1e-9; double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); - for (unsigned int i = 0; i < all_particles.size(); ++i ) + for (unsigned int i=0; i < all_particles.size(); ++i ) { core::XYZR xyzr = core::XYZR(all_particles[i]); double r = consider_radius_ ? xyzr.get_radius() : 0; double x = xyzr.get_coordinate(0); double y = xyzr.get_coordinate(1); double radial = std::sqrt(x*x + y*y); - double z_diff = radial - r - lower_bound_; - if ( z_diff < 0 ) + double r_down = consider_radius_ ? radial - r : radial; + double r_up = consider_radius_ ? radial + r : radial; + double r_diff = r_down - lower_bound_; + // check lower_bound_ + if ( r_diff < 0 ) { - v += z_diff*z_diff; + v += r_diff*r_diff; if ( accum ) { algebra::Vector3D dz; if ( radial > eps ) { - dz[0] = 2*z_diff*x/(radial*sigma_); - dz[1] = 2*z_diff*y/(radial*sigma_); + double coeff = 2.0*r_diff/(radial*sigma_); + dz[0] = coeff * x; + dz[1] = coeff * y; } else { - dz[0] = dz[1] = 0; + dz[0] = dz[1] = 0.0; } - dz[2] = 0; + dz[2] = 0.0; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); + } + } + // check upper_bound_ + r_diff = r_up - upper_bound_; + if ( r_diff > 0 ) + { + v += r_diff*r_diff; + if ( accum ) + { + algebra::Vector3D dz; + if ( radial > eps ) + { + double coeff = 2.0*r_diff/(radial*sigma_); + dz[0] = coeff * x; + dz[1] = coeff * y; + } + else + { + dz[0] = dz[1] = 0.0; + } + dz[2] = 0.0; all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); } } @@ -206,8 +421,7 @@ XYRadialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accu return v/sigma_; } - -ModelObjectsTemp XYRadialPositionLowerRestraint::do_get_inputs() const { +ModelObjectsTemp XYRadialPositionRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); ParticleIndexes all = sc_->get_all_possible_indexes(); @@ -215,56 +429,57 @@ ModelObjectsTemp XYRadialPositionLowerRestraint::do_get_inputs() const { } - -XYRadialPositionUpperRestraint::XYRadialPositionUpperRestraint(Model *m, +/*##################################################### +# Restraints setup - Immuno-EM XYRadialPositionLowerRestraint +# Supplementary Table 7. Upper and lower bounds on R-radial restraints of C-terminal bead of nups +# NupType : (min R value, max R value) (in Angstrom) +#####################################################*/ +XYRadialPositionLowerRestraint::XYRadialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, - double upper_bound, bool consider_radius, double sigma) - : Restraint(m, "XYRadialPositionUpperRestraint %1%") - , upper_bound_(upper_bound) + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) , sigma_(sigma) , consider_radius_(consider_radius) { sc_ = sc; } - -XYRadialPositionUpperRestraint::XYRadialPositionUpperRestraint(Model *m, - double upper_bound, bool consider_radius, double sigma) - : Restraint(m, "XYRadialPositionUpperRestraint %1%") - , upper_bound_(upper_bound) +XYRadialPositionLowerRestraint::XYRadialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "XYRadialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) , sigma_(sigma) , consider_radius_(consider_radius) { } - -void XYRadialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { +void XYRadialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( - ps[0]->get_model(), "XY Radial list"); + ps[0]->get_model(), "XY radial list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); } -void XYRadialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { +void XYRadialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( - ps[0]->get_model(), "XY Radial list"); + ps[0]->get_model(), "XY radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); } -void XYRadialPositionUpperRestraint::add_particle(Particle *ps) { +void XYRadialPositionLowerRestraint::add_particle(Particle *ps) { if (!sc_) { sc_ = new IMP::internal::StaticListContainer( - ps->get_model(), "XY Radial list"); + ps->get_model(), "XY radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); } - double -XYRadialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +XYRadialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); const double eps = 1e-9; @@ -277,8 +492,8 @@ XYRadialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accu double x = xyzr.get_coordinate(0); double y = xyzr.get_coordinate(1); double radial = std::sqrt(x*x + y*y); - double z_diff = radial + r - upper_bound_; - if ( z_diff > 0 ) + double z_diff = radial - r - lower_bound_; + if ( z_diff < 0 ) { v += z_diff*z_diff; if ( accum ) @@ -301,8 +516,7 @@ XYRadialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accu return v/sigma_; } - -ModelObjectsTemp XYRadialPositionUpperRestraint::do_get_inputs() const { +ModelObjectsTemp XYRadialPositionLowerRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); ParticleIndexes all = sc_->get_all_possible_indexes(); @@ -310,11 +524,15 @@ ModelObjectsTemp XYRadialPositionUpperRestraint::do_get_inputs() const { } - -ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, +/*##################################################### +# Restraints setup - Immuno-EM XYRadialPositionUpperRestraint +# Supplementary Table 7. Upper and lower bounds on R-radial restraints of C-terminal bead of nups +# NupType : (min R value, max R value) (in Angstrom) +#####################################################*/ +XYRadialPositionUpperRestraint::XYRadialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, double upper_bound, bool consider_radius, double sigma) - : Restraint(m, "ZAxialPositionUpperRestraint %1%") + : Restraint(m, "XYRadialPositionUpperRestraint %1%") , upper_bound_(upper_bound) , sigma_(sigma) , consider_radius_(consider_radius) @@ -322,62 +540,70 @@ ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, sc_ = sc; } - -ZAxialPositionUpperRestraint::ZAxialPositionUpperRestraint(Model *m, +XYRadialPositionUpperRestraint::XYRadialPositionUpperRestraint(Model *m, double upper_bound, bool consider_radius, double sigma) - : Restraint(m, "ZAxialPositionUpperRestraint %1%") + : Restraint(m, "XYRadialPositionUpperRestraint %1%") , upper_bound_(upper_bound) , sigma_(sigma) , consider_radius_(consider_radius) { } - -void ZAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { +void XYRadialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( - ps[0]->get_model(), "Z axial list"); + ps[0]->get_model(), "XY Radial list"); } get_list(sc_)->set(IMP::internal::get_index(ps)); } -void ZAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { +void XYRadialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { if (!sc_&& !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( - ps[0]->get_model(), "Z axial list"); + ps[0]->get_model(), "XY Radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); } -void ZAxialPositionUpperRestraint::add_particle(Particle *ps) { +void XYRadialPositionUpperRestraint::add_particle(Particle *ps) { if (!sc_) { sc_ = new IMP::internal::StaticListContainer( - ps->get_model(), "Z axial list"); + ps->get_model(), "XY Radial list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); } - double -ZAxialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +XYRadialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); + const double eps = 1e-9; double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) { - double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0; - double z = core::XYZR(all_particles[i]).get_coordinate(2); - double z_up = z + r; - double z_diff = z_up - upper_bound_; + core::XYZR xyzr = core::XYZR(all_particles[i]); + double r = consider_radius_ ? xyzr.get_radius() : 0; + double x = xyzr.get_coordinate(0); + double y = xyzr.get_coordinate(1); + double radial = std::sqrt(x*x + y*y); + double z_diff = radial + r - upper_bound_; if ( z_diff > 0 ) { v += z_diff*z_diff; if ( accum ) { algebra::Vector3D dz; - dz[0] = dz[1] = 0; - dz[2] = 2*z_diff/sigma_; + if ( radial > eps ) + { + dz[0] = 2*z_diff*x/(radial*sigma_); + dz[1] = 2*z_diff*y/(radial*sigma_); + } + else + { + dz[0] = dz[1] = 0; + } + dz[2] = 0; all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); } } @@ -385,8 +611,7 @@ ZAxialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) return v/sigma_; } - -ModelObjectsTemp ZAxialPositionUpperRestraint::do_get_inputs() const { +ModelObjectsTemp XYRadialPositionUpperRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); ParticleIndexes all = sc_->get_all_possible_indexes(); @@ -394,7 +619,9 @@ ModelObjectsTemp ZAxialPositionUpperRestraint::do_get_inputs() const { } - +/*##################################################### +# Restraints setup - ProteinContactRestraint +#####################################################*/ ProteinContactRestraint::ProteinContactRestraint(Model *m, SingletonContainerAdaptor sc, double tolerance_factor, double sigma) @@ -405,7 +632,6 @@ ProteinContactRestraint::ProteinContactRestraint(Model *m, sc_ = sc; } - ProteinContactRestraint::ProteinContactRestraint(Model *m, double tolerance_factor, double sigma) : Restraint(m, "ProteinContactRestraint %1%") @@ -414,7 +640,6 @@ ProteinContactRestraint::ProteinContactRestraint(Model *m, { } - void ProteinContactRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -439,7 +664,6 @@ void ProteinContactRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double ProteinContactRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -482,7 +706,6 @@ ProteinContactRestraint::unprotected_evaluate(DerivativeAccumulator *accum) cons return v/sigma_; } - ModelObjectsTemp ProteinContactRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); @@ -491,7 +714,9 @@ ModelObjectsTemp ProteinContactRestraint::do_get_inputs() const { } - +/*##################################################### +# Restraints setup - ProteinChainRestraint +#####################################################*/ ProteinChainRestraint::ProteinChainRestraint(Model *m, SingletonContainerAdaptor sc, double sigma) @@ -501,7 +726,6 @@ ProteinChainRestraint::ProteinChainRestraint(Model *m, sc_ = sc; } - ProteinChainRestraint::ProteinChainRestraint(Model *m, double sigma) : Restraint(m, "ProteinChainRestraint %1%") @@ -509,7 +733,6 @@ ProteinChainRestraint::ProteinChainRestraint(Model *m, { } - void ProteinChainRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -534,7 +757,6 @@ void ProteinChainRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double ProteinChainRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -571,7 +793,6 @@ ProteinChainRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const return v/sigma_; } - ModelObjectsTemp ProteinChainRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); @@ -580,10 +801,11 @@ ModelObjectsTemp ProteinChainRestraint::do_get_inputs() const { } +/*##################################################### +# Function setup - half_torus_distance +#####################################################*/ namespace { - - std::pair half_torus_distance(double x, double y, double z, double R, double r) { const double eps = 1e-9; @@ -647,11 +869,12 @@ std::pair half_torus_distance(double x, double y, dou return std::make_pair(-denom, der); } } - - } +/*##################################################### +# Restraints setup - MembraneSurfaceLocationRestraint +#####################################################*/ MembraneSurfaceLocationRestraint::MembraneSurfaceLocationRestraint(Model *m, SingletonContainerAdaptor sc, double R, double r, double thickness, double sigma) @@ -664,7 +887,6 @@ MembraneSurfaceLocationRestraint::MembraneSurfaceLocationRestraint(Model *m, sc_ = sc; } - MembraneSurfaceLocationRestraint::MembraneSurfaceLocationRestraint(Model *m, double R, double r, double thickness, double sigma) : Restraint(m, "MembraneSurfaceLocationRestraint %1%") @@ -675,7 +897,6 @@ MembraneSurfaceLocationRestraint::MembraneSurfaceLocationRestraint(Model *m, { } - void MembraneSurfaceLocationRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -700,7 +921,6 @@ void MembraneSurfaceLocationRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double MembraneSurfaceLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -730,7 +950,6 @@ MembraneSurfaceLocationRestraint::unprotected_evaluate(DerivativeAccumulator *ac return v/sigma_; } - ModelObjectsTemp MembraneSurfaceLocationRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); @@ -739,7 +958,9 @@ ModelObjectsTemp MembraneSurfaceLocationRestraint::do_get_inputs() const { } - +/*##################################################### +# Restraints setup - PoreSideVolumeLocationRestraint +#####################################################*/ PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, double R, double r, double thickness, @@ -754,7 +975,6 @@ PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, sc_ = sc; } - PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, double R, double r, double thickness, bool consider_radius, double sigma) @@ -767,7 +987,6 @@ PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, { } - void PoreSideVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -792,7 +1011,6 @@ void PoreSideVolumeLocationRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double PerinuclearVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -824,7 +1042,6 @@ PerinuclearVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator * return v/sigma_; } - ModelObjectsTemp PoreSideVolumeLocationRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); @@ -833,7 +1050,9 @@ ModelObjectsTemp PoreSideVolumeLocationRestraint::do_get_inputs() const { } - +/*##################################################### +# Restraints setup - PerinuclearVolumeLocationRestraint +#####################################################*/ PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, double R, double r, double thickness, @@ -848,7 +1067,6 @@ PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, sc_ = sc; } - PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, double R, double r, double thickness, bool consider_radius, double sigma) @@ -861,7 +1079,6 @@ PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, { } - void PerinuclearVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -886,7 +1103,6 @@ void PerinuclearVolumeLocationRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double PoreSideVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -918,7 +1134,6 @@ PoreSideVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *acc return v/sigma_; } - ModelObjectsTemp PerinuclearVolumeLocationRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); @@ -927,7 +1142,9 @@ ModelObjectsTemp PerinuclearVolumeLocationRestraint::do_get_inputs() const { } - +/*##################################################### +# Restraints setup - AssemblySymmetryByDistanceRestraint +#####################################################*/ AssemblySymmetryByDistanceRestraint::AssemblySymmetryByDistanceRestraint(Model *m, SingletonContainerAdaptor sc, double sigma) @@ -937,7 +1154,6 @@ AssemblySymmetryByDistanceRestraint::AssemblySymmetryByDistanceRestraint(Model * sc_ = sc; } - AssemblySymmetryByDistanceRestraint::AssemblySymmetryByDistanceRestraint(Model *m, double sigma) : Restraint(m, "AssemblySymmetryByDistanceRestraint %1%") @@ -945,7 +1161,6 @@ AssemblySymmetryByDistanceRestraint::AssemblySymmetryByDistanceRestraint(Model * { } - void AssemblySymmetryByDistanceRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -970,7 +1185,6 @@ void AssemblySymmetryByDistanceRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double AssemblySymmetryByDistanceRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -1006,8 +1220,17 @@ AssemblySymmetryByDistanceRestraint::unprotected_evaluate(DerivativeAccumulator return diff*diff/sigma_; } +ModelObjectsTemp AssemblySymmetryByDistanceRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} +/*##################################################### +# Restraints setup - AssemblySymmetryByDihedralRestraint +#####################################################*/ AssemblySymmetryByDihedralRestraint::AssemblySymmetryByDihedralRestraint(Model *m, SingletonContainerAdaptor sc, double sigma) @@ -1017,7 +1240,6 @@ AssemblySymmetryByDihedralRestraint::AssemblySymmetryByDihedralRestraint(Model * sc_ = sc; } - AssemblySymmetryByDihedralRestraint::AssemblySymmetryByDihedralRestraint(Model *m, double sigma) : Restraint(m, "AssemblySymmetryByDihedralRestraint %1%") @@ -1025,7 +1247,6 @@ AssemblySymmetryByDihedralRestraint::AssemblySymmetryByDihedralRestraint(Model * { } - void AssemblySymmetryByDihedralRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -1050,7 +1271,6 @@ void AssemblySymmetryByDihedralRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double AssemblySymmetryByDihedralRestraint::unprotected_evaluate(DerivativeAccumulator * /*accum*/) const { @@ -1067,15 +1287,6 @@ AssemblySymmetryByDihedralRestraint::unprotected_evaluate(DerivativeAccumulator return diff*diff/sigma_; } - -ModelObjectsTemp AssemblySymmetryByDistanceRestraint::do_get_inputs() const { - if ( !sc_ ) - return ModelObjectsTemp(); - ParticleIndexes all = sc_->get_all_possible_indexes(); - return IMP::get_particles(get_model(), all); -} - - ModelObjectsTemp AssemblySymmetryByDihedralRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); @@ -1084,7 +1295,9 @@ ModelObjectsTemp AssemblySymmetryByDihedralRestraint::do_get_inputs() const { } - +/*##################################################### +# Restraints setup - ProteinProximityRestraint +#####################################################*/ ProteinProximityRestraint::ProteinProximityRestraint(Model *m, SingletonContainerAdaptor sc, double max_dist, double sigma) @@ -1095,7 +1308,6 @@ ProteinProximityRestraint::ProteinProximityRestraint(Model *m, sc_ = sc; } - ProteinProximityRestraint::ProteinProximityRestraint(Model *m, double max_dist, double sigma) : Restraint(m, "ProteinProximityRestraint %1%") @@ -1104,7 +1316,6 @@ ProteinProximityRestraint::ProteinProximityRestraint(Model *m, { } - void ProteinProximityRestraint::set_particles(const ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( @@ -1129,7 +1340,6 @@ void ProteinProximityRestraint::add_particle(Particle *ps) { get_list(sc_)->add(IMP::internal::get_index(ps)); } - double ProteinProximityRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { @@ -1168,7 +1378,6 @@ ProteinProximityRestraint::unprotected_evaluate(DerivativeAccumulator *accum) co return v/sigma_; } - ModelObjectsTemp ProteinProximityRestraint::do_get_inputs() const { if ( !sc_ ) return ModelObjectsTemp(); From e2c0960ec0055523aa91048def04583da2c2a89a Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Sat, 4 Jun 2016 16:43:28 -0700 Subject: [PATCH 029/491] update & add an option for FG nups --- pyext/src/npc_restraints.py | 188 +++++++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 1 deletion(-) diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index e8a3af3e37..26984df95a 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -1,5 +1,5 @@ import IMP.npc - +import IMP.pmi.representation class XYRadialPositionRestraint(object): """Create XYRadial Position Lower restraints @@ -358,3 +358,189 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) + + +class Representation(IMP.pmi.representation.Representation): + """ NPC specific functions are defined here + """ + def set_coordinates_from_rmf(self, component_name, rmf_file_name, + rmf_frame_number, + rmf_component_name=None, + check_number_particles=True, + representation_name_to_rmf_name_map=None, + state_number=0, + skip_gaussian_in_rmf=False, + skip_gaussian_in_representation=False, + save_file=False): + '''Read and replace coordinates from an RMF file. + Replace the coordinates of particles with the same name. + It assumes that the RMF and the representation have the particles + in the same order. + @param component_name Component name + @param rmf_component_name Name of the component in the RMF file + (if not specified, use `component_name`) + @param representation_name_to_rmf_name_map a dictionary that map + the original rmf particle name to the recipient particle component name + @param save_file: save a file with the names of particles of the component + + ''' + import IMP.pmi.analysis + + prots = IMP.pmi.analysis.get_hiers_from_rmf( + self.m, + rmf_frame_number, + rmf_file_name) + + if not prots: + raise ValueError("cannot read hierarchy from rmf") + + prot=prots[0] + + # if len(self.rigid_bodies)!=0: + # print "set_coordinates_from_rmf: cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" + # exit() + + allpsrmf = IMP.atom.get_leaves(prot) + psrmf = [] + for p in allpsrmf: + (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( + p, self.hier_dict.keys()) + if (protname is None) and (rmf_component_name is not None): + (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( + p, rmf_component_name) + if (skip_gaussian_in_rmf): + if (IMP.core.Gaussian.get_is_setup(p)) and not (IMP.atom.Fragment.get_is_setup(p) or IMP.atom.Residue.get_is_setup(p)): + continue + ################################### + # by SJ Kim (06/04/2016) + ################################### + """ + if (protname is None): + continue + #else: + #print (p, p.get_parent().get_parent().get_name(), protname, is_a_bead) + self_names=(p.get_name()).replace("-","_").split("_") + #print(self_names, is_a_bead) + #print (self_names, protname[0:8], len(self_names)) + if (len(self_names) > 1) : + residue_no = int(self_names[1]) + elif (len(self_names) == 1) : + residue_no = int(self_names[0]) + else: + residue_no = int(0) + + if (protname[0:6] == "Nup116") and (is_a_bead) : + if (int(self_names[1]) < 751) : + continue + elif (protname[0:8] == "Nup159.1") : + #if (int(self_names[1]) > 381) and (int(self_names[1]) < 1117) : + if (residue_no < 1117) : + #print(self_names, protname[0:8], is_a_bead) + continue + elif (protname[0:4] == "Nsp1") and (is_a_bead) : + if (int(self_names[1]) < 637) : + continue + + #if (protname[0:6] == "Nup159"): + # print(self_names) + #exit(0) + """ + ################################### + if (rmf_component_name is not None) and (protname == rmf_component_name): + psrmf.append(p) + elif (rmf_component_name is None) and (protname == component_name): + psrmf.append(p) + + psrepr = IMP.atom.get_leaves(self.hier_dict[component_name]) + if (skip_gaussian_in_representation): + allpsrepr = psrepr + psrepr = [] + for p in allpsrepr: + #(protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( + # p, self.hier_dict.keys()) + if (IMP.core.Gaussian.get_is_setup(p)) and not (IMP.atom.Fragment.get_is_setup(p) or IMP.atom.Residue.get_is_setup(p)): + continue + ################################### + # by SJ Kim (06/04/2016) + ################################### + """ + (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( + p, self.hier_dict.keys()) + if (protname is None) and (rmf_component_name is not None): + (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( + p, rmf_component_name) + if (protname is None): + continue + + self_names=(p.get_name()).replace("-","_").split("_") + if (len(self_names) > 1) : + if (protname[0:6] == "Nup116") and (is_a_bead) : + if (int(self_names[1]) < 751) : + continue + elif (protname[0:6] == "Nup159") and (is_a_bead) : + if (int(self_names[1]) > 381) and (int(self_names[1]) < 1117) : + continue + elif (protname[0:4] == "Nsp1") and (is_a_bead) : + if (int(self_names[1]) < 637) : + continue + """ + ################################### + psrepr.append(p) + + import itertools + reprnames=[p.get_name() for p in psrepr] + rmfnames=[p.get_name() for p in psrmf] + + if save_file: + fl=open(component_name+".txt","w") + for i in itertools.izip_longest(reprnames,rmfnames): fl.write(str(i[0])+","+str(i[1])+"\n") + + + if check_number_particles and not representation_name_to_rmf_name_map: + if len(psrmf) != len(psrepr): + fl=open(component_name+".txt","w") + for i in itertools.izip_longest(reprnames,rmfnames): fl.write(str(i[0])+","+str(i[1])+"\n") + raise ValueError("%s cannot proceed the rmf and the representation don't have the same number of particles; " + "particles in rmf: %s particles in the representation: %s" % (str(component_name), str(len(psrmf)), str(len(psrepr)))) + + + if not representation_name_to_rmf_name_map: + for n, prmf in enumerate(psrmf): + + prmfname = prmf.get_name() + preprname = psrepr[n].get_name() + if IMP.core.RigidMember.get_is_setup(psrepr[n]): + raise ValueError("component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name) + if IMP.core.NonRigidMember.get_is_setup(psrepr[n]): + raise ValueError("component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name) + + if prmfname != preprname: + print("set_coordinates_from_rmf: WARNING rmf particle and representation particles have not the same name %s %s " % (prmfname, preprname)) + if IMP.core.XYZ.get_is_setup(prmf) and IMP.core.XYZ.get_is_setup(psrepr[n]): + xyz = IMP.core.XYZ(prmf).get_coordinates() + IMP.core.XYZ(psrepr[n]).set_coordinates(xyz) + else: + print("set_coordinates_from_rmf: WARNING particles are not XYZ decorated %s %s " % (str(IMP.core.XYZ.get_is_setup(prmf)), str(IMP.core.XYZ.get_is_setup(psrepr[n])))) + + if IMP.core.Gaussian.get_is_setup(prmf) and IMP.core.Gaussian.get_is_setup(psrepr[n]): + gprmf=IMP.core.Gaussian(prmf) + grepr=IMP.core.Gaussian(psrepr[n]) + g=gprmf.get_gaussian() + grepr.set_gaussian(g) + + else: + repr_name_particle_map={} + rmf_name_particle_map={} + for p in psrmf: + rmf_name_particle_map[p.get_name()]=p + #for p in psrepr: + # repr_name_particle_map[p.get_name()]=p + + for prepr in psrepr: + try: + prmf=rmf_name_particle_map[representation_name_to_rmf_name_map[prepr.get_name()]] + except KeyError: + print("set_coordinates_from_rmf: WARNING missing particle name in representation_name_to_rmf_name_map, skipping...") + continue + xyz = IMP.core.XYZ(prmf).get_coordinates() + IMP.core.XYZ(prepr).set_coordinates(xyz) From 5ee7772710ece7369b4cfb7e197f40abe8eb8771 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Mon, 6 Jun 2016 00:06:30 -0700 Subject: [PATCH 030/491] add Membrane Localization Restraints + ALPS Motifs, and super-rigid bodies --- pyext/src/npc_restraints.py | 83 +++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 9 deletions(-) diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index 26984df95a..778a784b28 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -2,7 +2,7 @@ import IMP.pmi.representation class XYRadialPositionRestraint(object): - """Create XYRadial Position Lower restraints + """Create XYRadial Position Restraint """ def __init__(self, representation = None, @@ -11,6 +11,7 @@ def __init__(self, upper_bound = 0.0, consider_radius = False, sigma = 1.0, + term = 'C', hier = None): """Constructor @param representation representation @@ -31,10 +32,12 @@ def __init__(self, xyr = IMP.npc.XYRadialPositionRestraint(self.m, lower_bound, upper_bound, consider_radius, sigma) #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) - cterminal = residues[-1] #nterminal = residues[0] - #print (cterminal, type(cterminal)) - - xyr.add_particle(cterminal) + if (term == 'C'): + terminal = residues[-1] + else: + terminal = residues[0] + #print (terminal, type(terminal)) + xyr.add_particle(terminal) self.rs.add_restraint(xyr) def set_label(self, label): @@ -191,6 +194,7 @@ def __init__(self, upper_bound = 0.0, consider_radius = False, sigma = 1.0, + term = 'C', hier = None): """Constructor @param representation representation @@ -211,10 +215,12 @@ def __init__(self, zax = IMP.npc.ZAxialPositionRestraint(self.m, lower_bound, upper_bound, consider_radius, sigma) #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) - cterminal = residues[-1] #nterminal = residues[0] - #print (cterminal, type(cterminal)) - - zax.add_particle(cterminal) + if (term == 'C'): + terminal = residues[-1] + else: + terminal = residues[0] + #print (terminal, type(terminal)) + zax.add_particle(terminal) self.rs.add_restraint(zax) def set_label(self, label): @@ -360,6 +366,65 @@ def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) +class MembraneSurfaceLocationRestraint(object): + """Create Membrane Surface Location Restraint + """ + def __init__(self, + representation = None, + protein = None, + tor_R = 540.0, + tor_r = 127.5, + tor_th = 45.0, + sigma = 0.2, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("MembraneSurfaceLocationRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'MembraneSurfaceLocationRestraint') + self.weight=1.0 + self.label = "None" + + msl = IMP.npc.MembraneSurfaceLocationRestraint(self.m, tor_R, tor_r, tor_th, sigma) + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + for residue in residues: + #print (residue, type(residue)) + msl.add_particle(residue) + self.rs.add_restraint(msl) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["MembraneSurfaceLocationRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + + class Representation(IMP.pmi.representation.Representation): """ NPC specific functions are defined here """ From 92694c794f76345b2cb62367194155bfdbd35a34 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Tue, 14 Jun 2016 22:13:32 -0700 Subject: [PATCH 031/491] Restraints for the Pom152 ring --- pyext/src/npc_restraints.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index 778a784b28..f1b43f7497 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -34,10 +34,16 @@ def __init__(self, residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) if (term == 'C'): terminal = residues[-1] - else: + #print (terminal, type(terminal)) + xyr.add_particle(terminal) + elif (term == 'N'): terminal = residues[0] - #print (terminal, type(terminal)) - xyr.add_particle(terminal) + #print (terminal, type(terminal)) + xyr.add_particle(terminal) + else: + for residue in residues: + #print (residue, type(residue)) + xyr.add_particle(residue) self.rs.add_restraint(xyr) def set_label(self, label): @@ -217,10 +223,16 @@ def __init__(self, residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) if (term == 'C'): terminal = residues[-1] - else: + #print (terminal, type(terminal)) + zax.add_particle(terminal) + elif (term == 'N'): terminal = residues[0] - #print (terminal, type(terminal)) - zax.add_particle(terminal) + #print (terminal, type(terminal)) + zax.add_particle(terminal) + else: + for residue in residues: + #print (residue, type(residue)) + zax.add_particle(residue) self.rs.add_restraint(zax) def set_label(self, label): From 37eda3500d195acd7aeb1fa11e2c4e5e2cbf623e Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Tue, 28 Jun 2016 08:58:04 -0700 Subject: [PATCH 032/491] Work around Boost 1.60 bug. --- src/CompositeRestraint.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index 5f17b6983c..f63c01da44 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -5,6 +5,13 @@ * */ +// Work around Boost bug with adjacency_matrix in 1.60: +// https://svn.boost.org/trac/boost/ticket/11880 +#include +#if BOOST_VERSION == 106000 +# include +#endif + #include #include #include From 8f4f0eceb7bcd15eb5432abb4886fe5153092668 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Thu, 4 Aug 2016 06:01:38 -0700 Subject: [PATCH 033/491] Adjust ALPS motifs of Nup157 / Nup170 --- include/ProteinLocalizationRestraint.h | 100 ++++++- pyext/src/npc_restraints.py | 377 +++++++++++++------------ src/ProteinLocalizationRestraint.cpp | 297 ++++++++++++++++++- 3 files changed, 559 insertions(+), 215 deletions(-) diff --git a/include/ProteinLocalizationRestraint.h b/include/ProteinLocalizationRestraint.h index 5da669b9d6..e005c795f8 100644 --- a/include/ProteinLocalizationRestraint.h +++ b/include/ProteinLocalizationRestraint.h @@ -27,7 +27,7 @@ class IMPNPCEXPORT ZAxialPositionRestraint : public Restraint double sigma_; bool consider_radius_; public: - ZAxialPositionRestraint(Model *m, SingletonContainerAdaptor sc, + ZAxialPositionRestraint(Model *m, SingletonContainerAdaptor sc, double lower_bound, double upper_bound, bool consider_radius, double sigma=1); ZAxialPositionRestraint(Model *m, double lower_bound, double upper_bound, bool consider_radius, double sigma=1); @@ -75,7 +75,7 @@ class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint double sigma_; bool consider_radius_; public: - ZAxialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, + ZAxialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, double upper_bound, bool consider_radius, double sigma=1); ZAxialPositionUpperRestraint(Model *m, double upper_bound, bool consider_radius, double sigma=1); @@ -93,6 +93,80 @@ class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint }; +class IMPNPCEXPORT YAxialPositionRestraint : public Restraint +{ + IMP::PointerMember sc_; + double lower_bound_; + double upper_bound_; + double sigma_; + bool consider_radius_; +public: + YAxialPositionRestraint(Model *m, SingletonContainerAdaptor sc, + double lower_bound, double upper_bound, bool consider_radius, double sigma=1); + YAxialPositionRestraint(Model *m, + double lower_bound, double upper_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(YAxialPositionRestraint);; +}; + +class IMPNPCEXPORT YAxialPositionLowerRestraint : public Restraint +{ + IMP::PointerMember sc_; + double lower_bound_; + double sigma_; + bool consider_radius_; +public: + YAxialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, + double lower_bound, bool consider_radius, double sigma=1); + YAxialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(YAxialPositionLowerRestraint);; +}; + +class IMPNPCEXPORT YAxialPositionUpperRestraint : public Restraint +{ + IMP::PointerMember sc_; + double upper_bound_; + double sigma_; + bool consider_radius_; +public: + YAxialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, + double upper_bound, bool consider_radius, double sigma=1); + YAxialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma=1); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(YAxialPositionUpperRestraint);; +}; + + class IMPNPCEXPORT XYRadialPositionRestraint : public Restraint { IMP::PointerMember sc_; @@ -101,7 +175,7 @@ class IMPNPCEXPORT XYRadialPositionRestraint : public Restraint double sigma_; bool consider_radius_; public: - XYRadialPositionRestraint(Model *m, SingletonContainerAdaptor sc, + XYRadialPositionRestraint(Model *m, SingletonContainerAdaptor sc, double lower_bound, double upper_bound, bool consider_radius, double sigma=1); XYRadialPositionRestraint(Model *m, double lower_bound, double upper_bound, bool consider_radius, double sigma=1); @@ -125,7 +199,7 @@ class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint double sigma_; bool consider_radius_; public: - XYRadialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, + XYRadialPositionLowerRestraint(Model *m, SingletonContainerAdaptor sc, double lower_bound, bool consider_radius, double sigma=1); XYRadialPositionLowerRestraint(Model *m, double lower_bound, bool consider_radius, double sigma=1); @@ -149,7 +223,7 @@ class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint double sigma_; bool consider_radius_; public: - XYRadialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, + XYRadialPositionUpperRestraint(Model *m, SingletonContainerAdaptor sc, double upper_bound, bool consider_radius, double sigma=1); XYRadialPositionUpperRestraint(Model *m, double upper_bound, bool consider_radius, double sigma=1); @@ -173,7 +247,7 @@ class IMPNPCEXPORT ProteinContactRestraint : public Restraint double tolerance_factor_; double sigma_; public: - ProteinContactRestraint(Model *m, SingletonContainerAdaptor sc, + ProteinContactRestraint(Model *m, SingletonContainerAdaptor sc, double tolerance_factor, double sigma=0.1); ProteinContactRestraint(Model *m, double tolerance_factor, double sigma=0.1); @@ -196,7 +270,7 @@ class IMPNPCEXPORT ProteinChainRestraint : public Restraint IMP::PointerMember sc_; double sigma_; public: - ProteinChainRestraint(Model *m, SingletonContainerAdaptor sc, + ProteinChainRestraint(Model *m, SingletonContainerAdaptor sc, double sigma=0.1); ProteinChainRestraint(Model *m, double sigma=0.1); @@ -222,7 +296,7 @@ class IMPNPCEXPORT MembraneSurfaceLocationRestraint : public Restraint double sigma_; double thickness_; public: - MembraneSurfaceLocationRestraint(Model *m, SingletonContainerAdaptor sc, + MembraneSurfaceLocationRestraint(Model *m, SingletonContainerAdaptor sc, double R, double r, double thickness, double sigma=2); MembraneSurfaceLocationRestraint(Model *m, double R, double r, double thickness, double sigma=2); @@ -249,7 +323,7 @@ class IMPNPCEXPORT PoreSideVolumeLocationRestraint : public Restraint double thickness_; bool consider_radius_; public: - PoreSideVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, + PoreSideVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, double R, double r, double thickness, bool consider_radius, double sigma=2); PoreSideVolumeLocationRestraint(Model *m, double R, double r, double thickness, bool consider_radius, double sigma=2); @@ -276,7 +350,7 @@ class IMPNPCEXPORT PerinuclearVolumeLocationRestraint : public Restraint double thickness_; bool consider_radius_; public: - PerinuclearVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, + PerinuclearVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, double R, double r, double thickness, bool consider_radius, double sigma=2); PerinuclearVolumeLocationRestraint(Model *m, double R, double r, double thickness, bool consider_radius, double sigma=2); @@ -299,7 +373,7 @@ class IMPNPCEXPORT AssemblySymmetryByDistanceRestraint : public Restraint IMP::PointerMember sc_; double sigma_; public: - AssemblySymmetryByDistanceRestraint(Model *m, SingletonContainerAdaptor sc, + AssemblySymmetryByDistanceRestraint(Model *m, SingletonContainerAdaptor sc, double sigma=4); AssemblySymmetryByDistanceRestraint(Model *m, double sigma=4); @@ -323,7 +397,7 @@ class IMPNPCEXPORT AssemblySymmetryByDihedralRestraint IMP::PointerMember sc_; double sigma_; public: - AssemblySymmetryByDihedralRestraint(Model *m, SingletonContainerAdaptor sc, + AssemblySymmetryByDihedralRestraint(Model *m, SingletonContainerAdaptor sc, double sigma=0.1); AssemblySymmetryByDihedralRestraint(Model *m, double sigma=0.1); @@ -348,7 +422,7 @@ class IMPNPCEXPORT ProteinProximityRestraint double sigma_; double max_dist_; public: - ProteinProximityRestraint(Model *m, SingletonContainerAdaptor sc, + ProteinProximityRestraint(Model *m, SingletonContainerAdaptor sc, double max_dist, double sigma=0.1); ProteinProximityRestraint(Model *m, double max_dist, double sigma=0.1); diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index f1b43f7497..4ccea6c7c6 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -70,7 +70,6 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) - class XYRadialPositionLowerRestraint(object): """Create XYRadial Position Lower restraints """ @@ -130,7 +129,6 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) - class XYRadialPositionUpperRestraint(object): """Create XYRadial Position Upper restraints """ @@ -190,6 +188,7 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) + class ZAxialPositionRestraint(object): """Create Z-Axial Position restraints """ @@ -378,6 +377,194 @@ def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) +class YAxialPositionRestraint(object): + """Create Y-Axial Position restraints + """ + def __init__(self, + representation = None, + protein = None, + lower_bound = 0.0, + upper_bound = 0.0, + consider_radius = False, + sigma = 1.0, + term = 'C', + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("YAxialPositionRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'YAxialPositionRestraint') + self.weight=1.0 + self.label = "None" + + yax = IMP.npc.YAxialPositionRestraint(self.m, lower_bound, upper_bound, consider_radius, sigma) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + if (term == 'C'): + terminal = residues[-1] + #print (terminal, type(terminal)) + yax.add_particle(terminal) + elif (term == 'N'): + terminal = residues[0] + #print (terminal, type(terminal)) + yax.add_particle(terminal) + else: + for residue in residues: + #print (residue, type(residue)) + yax.add_particle(residue) + self.rs.add_restraint(yax) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["YAxialPositionRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + +class YAxialPositionLowerRestraint(object): + """Create Y-Axial Position Lower restraints + """ + def __init__(self, + representation = None, + protein = None, + lower_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("YAxialPositionLowerRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'YAxialPositionLowerRestraint') + self.weight=1.0 + self.label = "None" + + yax = IMP.npc.YAxialPositionLowerRestraint(self.m, lower_bound, consider_radius, sigma) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) + + yax.add_particle(cterminal) + self.rs.add_restraint(yax) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["YAxialPositionLowerRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + +class YAxialPositionUpperRestraint(object): + """Create Y-Axial Position Upper restraints + """ + def __init__(self, + representation = None, + protein = None, + upper_bound = 0.0, + consider_radius = False, + sigma = 1.0, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("YAxialPositionUpperRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'YAxialPositionUpperRestraint') + self.weight=1.0 + self.label = "None" + + yax = IMP.npc.YAxialPositionUpperRestraint(self.m, upper_bound, consider_radius, sigma) + #terminal_residue = IMP.pmi.tools.get_terminal_residue(representation, representation.hier_dict[protein], terminus="C") + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + cterminal = residues[-1] #nterminal = residues[0] + #print (cterminal, type(cterminal)) + + yax.add_particle(cterminal) + self.rs.add_restraint(yax) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["YAxialPositionUpperRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + + class MembraneSurfaceLocationRestraint(object): """Create Membrane Surface Location Restraint """ @@ -435,189 +622,3 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) - - -class Representation(IMP.pmi.representation.Representation): - """ NPC specific functions are defined here - """ - def set_coordinates_from_rmf(self, component_name, rmf_file_name, - rmf_frame_number, - rmf_component_name=None, - check_number_particles=True, - representation_name_to_rmf_name_map=None, - state_number=0, - skip_gaussian_in_rmf=False, - skip_gaussian_in_representation=False, - save_file=False): - '''Read and replace coordinates from an RMF file. - Replace the coordinates of particles with the same name. - It assumes that the RMF and the representation have the particles - in the same order. - @param component_name Component name - @param rmf_component_name Name of the component in the RMF file - (if not specified, use `component_name`) - @param representation_name_to_rmf_name_map a dictionary that map - the original rmf particle name to the recipient particle component name - @param save_file: save a file with the names of particles of the component - - ''' - import IMP.pmi.analysis - - prots = IMP.pmi.analysis.get_hiers_from_rmf( - self.m, - rmf_frame_number, - rmf_file_name) - - if not prots: - raise ValueError("cannot read hierarchy from rmf") - - prot=prots[0] - - # if len(self.rigid_bodies)!=0: - # print "set_coordinates_from_rmf: cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" - # exit() - - allpsrmf = IMP.atom.get_leaves(prot) - psrmf = [] - for p in allpsrmf: - (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( - p, self.hier_dict.keys()) - if (protname is None) and (rmf_component_name is not None): - (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( - p, rmf_component_name) - if (skip_gaussian_in_rmf): - if (IMP.core.Gaussian.get_is_setup(p)) and not (IMP.atom.Fragment.get_is_setup(p) or IMP.atom.Residue.get_is_setup(p)): - continue - ################################### - # by SJ Kim (06/04/2016) - ################################### - """ - if (protname is None): - continue - #else: - #print (p, p.get_parent().get_parent().get_name(), protname, is_a_bead) - self_names=(p.get_name()).replace("-","_").split("_") - #print(self_names, is_a_bead) - #print (self_names, protname[0:8], len(self_names)) - if (len(self_names) > 1) : - residue_no = int(self_names[1]) - elif (len(self_names) == 1) : - residue_no = int(self_names[0]) - else: - residue_no = int(0) - - if (protname[0:6] == "Nup116") and (is_a_bead) : - if (int(self_names[1]) < 751) : - continue - elif (protname[0:8] == "Nup159.1") : - #if (int(self_names[1]) > 381) and (int(self_names[1]) < 1117) : - if (residue_no < 1117) : - #print(self_names, protname[0:8], is_a_bead) - continue - elif (protname[0:4] == "Nsp1") and (is_a_bead) : - if (int(self_names[1]) < 637) : - continue - - #if (protname[0:6] == "Nup159"): - # print(self_names) - #exit(0) - """ - ################################### - if (rmf_component_name is not None) and (protname == rmf_component_name): - psrmf.append(p) - elif (rmf_component_name is None) and (protname == component_name): - psrmf.append(p) - - psrepr = IMP.atom.get_leaves(self.hier_dict[component_name]) - if (skip_gaussian_in_representation): - allpsrepr = psrepr - psrepr = [] - for p in allpsrepr: - #(protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( - # p, self.hier_dict.keys()) - if (IMP.core.Gaussian.get_is_setup(p)) and not (IMP.atom.Fragment.get_is_setup(p) or IMP.atom.Residue.get_is_setup(p)): - continue - ################################### - # by SJ Kim (06/04/2016) - ################################### - """ - (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( - p, self.hier_dict.keys()) - if (protname is None) and (rmf_component_name is not None): - (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( - p, rmf_component_name) - if (protname is None): - continue - - self_names=(p.get_name()).replace("-","_").split("_") - if (len(self_names) > 1) : - if (protname[0:6] == "Nup116") and (is_a_bead) : - if (int(self_names[1]) < 751) : - continue - elif (protname[0:6] == "Nup159") and (is_a_bead) : - if (int(self_names[1]) > 381) and (int(self_names[1]) < 1117) : - continue - elif (protname[0:4] == "Nsp1") and (is_a_bead) : - if (int(self_names[1]) < 637) : - continue - """ - ################################### - psrepr.append(p) - - import itertools - reprnames=[p.get_name() for p in psrepr] - rmfnames=[p.get_name() for p in psrmf] - - if save_file: - fl=open(component_name+".txt","w") - for i in itertools.izip_longest(reprnames,rmfnames): fl.write(str(i[0])+","+str(i[1])+"\n") - - - if check_number_particles and not representation_name_to_rmf_name_map: - if len(psrmf) != len(psrepr): - fl=open(component_name+".txt","w") - for i in itertools.izip_longest(reprnames,rmfnames): fl.write(str(i[0])+","+str(i[1])+"\n") - raise ValueError("%s cannot proceed the rmf and the representation don't have the same number of particles; " - "particles in rmf: %s particles in the representation: %s" % (str(component_name), str(len(psrmf)), str(len(psrepr)))) - - - if not representation_name_to_rmf_name_map: - for n, prmf in enumerate(psrmf): - - prmfname = prmf.get_name() - preprname = psrepr[n].get_name() - if IMP.core.RigidMember.get_is_setup(psrepr[n]): - raise ValueError("component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name) - if IMP.core.NonRigidMember.get_is_setup(psrepr[n]): - raise ValueError("component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name) - - if prmfname != preprname: - print("set_coordinates_from_rmf: WARNING rmf particle and representation particles have not the same name %s %s " % (prmfname, preprname)) - if IMP.core.XYZ.get_is_setup(prmf) and IMP.core.XYZ.get_is_setup(psrepr[n]): - xyz = IMP.core.XYZ(prmf).get_coordinates() - IMP.core.XYZ(psrepr[n]).set_coordinates(xyz) - else: - print("set_coordinates_from_rmf: WARNING particles are not XYZ decorated %s %s " % (str(IMP.core.XYZ.get_is_setup(prmf)), str(IMP.core.XYZ.get_is_setup(psrepr[n])))) - - if IMP.core.Gaussian.get_is_setup(prmf) and IMP.core.Gaussian.get_is_setup(psrepr[n]): - gprmf=IMP.core.Gaussian(prmf) - grepr=IMP.core.Gaussian(psrepr[n]) - g=gprmf.get_gaussian() - grepr.set_gaussian(g) - - else: - repr_name_particle_map={} - rmf_name_particle_map={} - for p in psrmf: - rmf_name_particle_map[p.get_name()]=p - #for p in psrepr: - # repr_name_particle_map[p.get_name()]=p - - for prepr in psrepr: - try: - prmf=rmf_name_particle_map[representation_name_to_rmf_name_map[prepr.get_name()]] - except KeyError: - print("set_coordinates_from_rmf: WARNING missing particle name in representation_name_to_rmf_name_map, skipping...") - continue - xyz = IMP.core.XYZ(prmf).get_coordinates() - IMP.core.XYZ(prepr).set_coordinates(xyz) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index 9777ac0c2d..3a6676de00 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -95,13 +95,13 @@ ZAxialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) cons double v = 0.0; IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i=0; i < all_particles.size(); ++i ) - { + { double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0.0; double z = core::XYZR(all_particles[i]).get_coordinate(2); double z_down = consider_radius_ ? z - r : z; double z_up = consider_radius_ ? z + r : z; double z_diff = z_down - lower_bound_; - // check lower_bound_ + // check lower_bound_ if ( z_diff < 0 ) { v += z_diff*z_diff; @@ -113,7 +113,7 @@ ZAxialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) cons all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); } } - // check upper_bound_ + // check upper_bound_ z_diff = z_up - upper_bound_; if ( z_diff > 0 ) { @@ -194,7 +194,7 @@ ZAxialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) - { + { double r = core::XYZR(all_particles[i]).get_radius(); double z = core::XYZR(all_particles[i]).get_coordinate(2); double z_down = consider_radius_ ? z - r : z; @@ -278,7 +278,7 @@ ZAxialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) - { + { double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0; double z = core::XYZR(all_particles[i]).get_coordinate(2); double z_up = z + r; @@ -306,6 +306,275 @@ ModelObjectsTemp ZAxialPositionUpperRestraint::do_get_inputs() const { } +/*##################################################### +# Restraints setup - Immuno-EM YAxialPositionRestraint +# Supplementary Table 7. Upper and lower bounds on Y-axial restraints of C-terminal bead of nups +# NupType : (min Y value, max Y value) (in Angstrom) +#####################################################*/ +YAxialPositionRestraint::YAxialPositionRestraint(Model *m, + SingletonContainerAdaptor sc, + double lower_bound, double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "YAxialPositionRestraint %1%") + , lower_bound_(lower_bound) + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + +YAxialPositionRestraint::YAxialPositionRestraint(Model *m, + double lower_bound, double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "YAxialPositionRestraint %1%") + , lower_bound_(lower_bound) + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + +void YAxialPositionRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Y axial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void YAxialPositionRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Y axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void YAxialPositionRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Y axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +double +YAxialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0.0; + IMP::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i=0; i < all_particles.size(); ++i ) + { + double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0.0; + double y = core::XYZR(all_particles[i]).get_coordinate(1); + double y_down = consider_radius_ ? y - r : y; + double y_up = consider_radius_ ? y + r : y; + double y_diff = y_down - lower_bound_; + // check lower_bound_ + if ( y_diff < 0 ) + { + v += y_diff*y_diff; + if ( accum ) + { + algebra::Vector3D dy; + dy[0] = dy[1] = 0.0; + dy[2] = 2.0*y_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dy, *accum); + } + } + // check upper_bound_ + y_diff = y_up - upper_bound_; + if ( y_diff > 0 ) + { + v += y_diff*y_diff; + if ( accum ) + { + algebra::Vector3D dy; + dy[0] = dy[1] = 0.0; + dy[2] = 2.0*y_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dy, *accum); + } + } + } + return v/sigma_; +} + +ModelObjectsTemp YAxialPositionRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + +/*##################################################### +# Restraints setup - Immuno-EM YAxialPositionLowerRestraint +# Supplementary Table 7. Upper and lower bounds on Y-axial restraints of C-terminal bead of nups +# NupType : (min Y value, max Y value) (in Angstrom) +#####################################################*/ +YAxialPositionLowerRestraint::YAxialPositionLowerRestraint(Model *m, + SingletonContainerAdaptor sc, + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "YAxialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + +YAxialPositionLowerRestraint::YAxialPositionLowerRestraint(Model *m, + double lower_bound, bool consider_radius, double sigma) + : Restraint(m, "YAxialPositionLowerRestraint %1%") + , lower_bound_(lower_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + +void YAxialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Y axial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void YAxialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Y axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void YAxialPositionLowerRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Y axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +double +YAxialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + double r = core::XYZR(all_particles[i]).get_radius(); + double y = core::XYZR(all_particles[i]).get_coordinate(1); + double y_down = consider_radius_ ? y - r : y; + double y_diff = y_down - lower_bound_; + if ( y_diff < 0 ) + { + v += y_diff*y_diff; + if ( accum ) + { + algebra::Vector3D dy; + dy[0] = dy[1] = 0; + dy[2] = 2*y_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dy, *accum); + } + } + } + return v/sigma_; +} + +ModelObjectsTemp YAxialPositionLowerRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + +/*##################################################### +# Restraints setup - Immuno-EM YAxialPositionUpperRestraint +# Supplementary Table 7. Upper and lower bounds on Y-axial restraints of C-terminal bead of nups +# NupType : (min Y value, max Y value) (in Angstrom) +#####################################################*/ +YAxialPositionUpperRestraint::YAxialPositionUpperRestraint(Model *m, + SingletonContainerAdaptor sc, + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "YAxialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ + sc_ = sc; +} + +YAxialPositionUpperRestraint::YAxialPositionUpperRestraint(Model *m, + double upper_bound, bool consider_radius, double sigma) + : Restraint(m, "YAxialPositionUpperRestraint %1%") + , upper_bound_(upper_bound) + , sigma_(sigma) + , consider_radius_(consider_radius) +{ +} + +void YAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Y axial list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void YAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Y axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void YAxialPositionUpperRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Y axial list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +double +YAxialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + double r = consider_radius_ ? core::XYZR(all_particles[i]).get_radius() : 0; + double y = core::XYZR(all_particles[i]).get_coordinate(1); + double y_up = y + r; + double y_diff = y_up - upper_bound_; + if ( y_diff > 0 ) + { + v += y_diff*y_diff; + if ( accum ) + { + algebra::Vector3D dy; + dy[0] = dy[1] = 0; + dy[2] = 2*y_diff/sigma_; + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dy, *accum); + } + } + } + return v/sigma_; +} + +ModelObjectsTemp YAxialPositionUpperRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + /*##################################################### # Restraints setup - Immuno-EM XYRadialPositionRestraint # Supplementary Table 7. Upper and lower bounds on R-radial restraints of C-terminal bead of nups @@ -365,7 +634,7 @@ XYRadialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) co double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i=0; i < all_particles.size(); ++i ) - { + { core::XYZR xyzr = core::XYZR(all_particles[i]); double r = consider_radius_ ? xyzr.get_radius() : 0; double x = xyzr.get_coordinate(0); @@ -374,7 +643,7 @@ XYRadialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) co double r_down = consider_radius_ ? radial - r : radial; double r_up = consider_radius_ ? radial + r : radial; double r_diff = r_down - lower_bound_; - // check lower_bound_ + // check lower_bound_ if ( r_diff < 0 ) { v += r_diff*r_diff; @@ -395,7 +664,7 @@ XYRadialPositionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) co all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dz, *accum); } } - // check upper_bound_ + // check upper_bound_ r_diff = r_up - upper_bound_; if ( r_diff > 0 ) { @@ -486,7 +755,7 @@ XYRadialPositionLowerRestraint::unprotected_evaluate(DerivativeAccumulator *accu double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) - { + { core::XYZR xyzr = core::XYZR(all_particles[i]); double r = consider_radius_ ? xyzr.get_radius() : 0; double x = xyzr.get_coordinate(0); @@ -581,7 +850,7 @@ XYRadialPositionUpperRestraint::unprotected_evaluate(DerivativeAccumulator *accu double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); for (unsigned int i = 0; i < all_particles.size(); ++i ) - { + { core::XYZR xyzr = core::XYZR(all_particles[i]); double r = consider_radius_ ? xyzr.get_radius() : 0; double x = xyzr.get_coordinate(0); @@ -963,7 +1232,7 @@ ModelObjectsTemp MembraneSurfaceLocationRestraint::do_get_inputs() const { #####################################################*/ PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, - double R, double r, double thickness, + double R, double r, double thickness, bool consider_radius, double sigma) : Restraint(m, "PoreSideVolumeLocationRestraint %1%") , R_(R) @@ -976,7 +1245,7 @@ PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, } PoreSideVolumeLocationRestraint::PoreSideVolumeLocationRestraint(Model *m, - double R, double r, double thickness, + double R, double r, double thickness, bool consider_radius, double sigma) : Restraint(m, "PoreSideVolumeLocationRestraint %1%") , R_(R) @@ -1055,7 +1324,7 @@ ModelObjectsTemp PoreSideVolumeLocationRestraint::do_get_inputs() const { #####################################################*/ PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, SingletonContainerAdaptor sc, - double R, double r, double thickness, + double R, double r, double thickness, bool consider_radius, double sigma) : Restraint(m, "PerinuclearVolumeLocationRestraint %1%") , R_(R) @@ -1068,7 +1337,7 @@ PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, } PerinuclearVolumeLocationRestraint::PerinuclearVolumeLocationRestraint(Model *m, - double R, double r, double thickness, + double R, double r, double thickness, bool consider_radius, double sigma) : Restraint(m, "PerinuclearVolumeLocationRestraint %1%") , R_(R) From 3aa4eab906a91d4d527a49d30f5a1a4978a6afe8 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Wed, 7 Sep 2016 18:16:56 -0700 Subject: [PATCH 034/491] bug fix for the membrane surface restraint --- src/ProteinLocalizationRestraint.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index 3a6676de00..9b24d3b58c 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -1199,6 +1199,7 @@ MembraneSurfaceLocationRestraint::unprotected_evaluate(DerivativeAccumulator *ac for (unsigned int i = 0; i < all_particles.size(); ++i ) { core::XYZ i_current = core::XYZ(all_particles[i]); + /* double z = i_current.get_coordinate(2); if ( z > r_ ) z = r_; @@ -1206,6 +1207,9 @@ MembraneSurfaceLocationRestraint::unprotected_evaluate(DerivativeAccumulator *ac z = -r_; std::pair dist = half_torus_distance(i_current.get_coordinate(0), i_current.get_coordinate(1), z, R_, r_); + */ + std::pair dist = half_torus_distance(i_current.get_coordinate(0), + i_current.get_coordinate(1), i_current.get_coordinate(2), R_, r_); if ( std::fabs(dist.first) > thickness_ ) { v += dist.first*dist.first; From 3b04b897dc90f47aed8c0c4265ce25e8352eb0f9 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Thu, 22 Sep 2016 00:29:34 -0700 Subject: [PATCH 035/491] Add a test version of the membrane exclusion restraint --- include/ProteinLocalizationRestraint.h | 26 +++++++ pyext/src/npc_restraints.py | 63 ++++++++++++++++- src/ProteinLocalizationRestraint.cpp | 96 ++++++++++++++++++++++++-- 3 files changed, 178 insertions(+), 7 deletions(-) diff --git a/include/ProteinLocalizationRestraint.h b/include/ProteinLocalizationRestraint.h index e005c795f8..cf2b8b989b 100644 --- a/include/ProteinLocalizationRestraint.h +++ b/include/ProteinLocalizationRestraint.h @@ -314,6 +314,32 @@ class IMPNPCEXPORT MembraneSurfaceLocationRestraint : public Restraint }; +class IMPNPCEXPORT MembraneExclusionRestraint : public Restraint +{ + IMP::PointerMember sc_; + double R_; + double r_; + double sigma_; + double thickness_; +public: + MembraneExclusionRestraint(Model *m, SingletonContainerAdaptor sc, + double R, double r, double thickness, double sigma=2); + MembraneExclusionRestraint(Model *m, + double R, double r, double thickness, double sigma=2); + +#ifndef IMP_DOXYGEN + void add_particle(Particle *p); + void add_particles(const ParticlesTemp &ps); + void set_particles(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(MembraneExclusionRestraint);; +}; + + class IMPNPCEXPORT PoreSideVolumeLocationRestraint : public Restraint { IMP::PointerMember sc_; diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index 4ccea6c7c6..7df942861c 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -575,6 +575,7 @@ def __init__(self, tor_r = 127.5, tor_th = 45.0, sigma = 0.2, + resolution = 1, hier = None): """Constructor @param representation representation @@ -593,7 +594,7 @@ def __init__(self, self.label = "None" msl = IMP.npc.MembraneSurfaceLocationRestraint(self.m, tor_R, tor_r, tor_th, sigma) - residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=1) + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=resolution) for residue in residues: #print (residue, type(residue)) msl.add_particle(residue) @@ -622,3 +623,63 @@ def get_output(self): def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) + + +class MembraneExclusionRestraint(object): + """Create Membrane Exclusion Restraint + """ + def __init__(self, + representation = None, + protein = None, + tor_R = 540.0, + tor_r = 127.5, + tor_th = 45.0, + sigma = 0.2, + resolution = 1, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("MembraneExclusionRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'MembraneExclusionRestraint') + self.weight=1.0 + self.label = "None" + + mex = IMP.npc.MembraneExclusionRestraint(self.m, tor_R, tor_r, tor_th, sigma) + residues = IMP.pmi.tools.select_by_tuple(representation, protein, resolution=resolution) + for residue in residues: + #print (residue, type(residue)) + mex.add_particle(residue) + self.rs.add_restraint(mex) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["MembraneExclusionRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index 9b24d3b58c..c928a601f5 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -1231,6 +1231,90 @@ ModelObjectsTemp MembraneSurfaceLocationRestraint::do_get_inputs() const { } +/*##################################################### +# Restraints setup - MembraneExclusionRestraint +#####################################################*/ +MembraneExclusionRestraint::MembraneExclusionRestraint(Model *m, + SingletonContainerAdaptor sc, + double R, double r, double thickness, double sigma) + : Restraint(m, "MembraneExclusionRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) +{ + sc_ = sc; +} + +MembraneExclusionRestraint::MembraneExclusionRestraint(Model *m, + double R, double r, double thickness, double sigma) + : Restraint(m, "MembraneExclusionRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) +{ +} + +void MembraneExclusionRestraint::set_particles(const ParticlesTemp &ps) { + if (!sc_ && !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Membrane exclusion list"); + } + get_list(sc_)->set(IMP::internal::get_index(ps)); +} + +void MembraneExclusionRestraint::add_particles(const ParticlesTemp &ps) { + if (!sc_&& !ps.empty()) { + sc_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Membrane exclusion list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +void MembraneExclusionRestraint::add_particle(Particle *ps) { + if (!sc_) { + sc_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Membrane exclusion list"); + } + get_list(sc_)->add(IMP::internal::get_index(ps)); +} + +double +MembraneExclusionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc_.get()); + double v = 0; + IMP::ParticlesTemp all_particles = sc_->get(); + for (unsigned int i = 0; i < all_particles.size(); ++i ) + { + core::XYZ i_current = core::XYZ(all_particles[i]); + if ( std::fabs(i_current.get_coordinate(2)) > (r_ + thickness_) ) + continue; + + std::pair dist = half_torus_distance(i_current.get_coordinate(0), + i_current.get_coordinate(1), i_current.get_coordinate(2), R_, r_); + if ( dist.first < thickness_ ) + { + v += (thickness_ - dist.first) * (thickness_ - dist.first); + if ( accum ) + { + all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), + dist.second*2*dist.first/sigma_, *accum); + } + } + } + return v/sigma_; +} + +ModelObjectsTemp MembraneExclusionRestraint::do_get_inputs() const { + if ( !sc_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + /*##################################################### # Restraints setup - PoreSideVolumeLocationRestraint #####################################################*/ @@ -1285,7 +1369,7 @@ void PoreSideVolumeLocationRestraint::add_particle(Particle *ps) { } double -PerinuclearVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +PoreSideVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); double v = 0; @@ -1301,8 +1385,8 @@ PerinuclearVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator * std::pair dist = half_torus_distance(i_current.get_coordinate(0), i_current.get_coordinate(1), z, R_, r_); double radius = consider_radius_ ? i_current.get_radius() : 0; - dist.first += radius + thickness_; - if ( dist.first > 0 ) + dist.first -= radius + thickness_; + if ( dist.first < 0 ) { v += dist.first*dist.first; if ( accum ) @@ -1377,7 +1461,7 @@ void PerinuclearVolumeLocationRestraint::add_particle(Particle *ps) { } double -PoreSideVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +PerinuclearVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); double v = 0; @@ -1393,8 +1477,8 @@ PoreSideVolumeLocationRestraint::unprotected_evaluate(DerivativeAccumulator *acc std::pair dist = half_torus_distance(i_current.get_coordinate(0), i_current.get_coordinate(1), z, R_, r_); double radius = consider_radius_ ? i_current.get_radius() : 0; - dist.first -= radius + thickness_; - if ( dist.first < 0 ) + dist.first += radius + thickness_; + if ( dist.first > 0 ) { v += dist.first*dist.first; if ( accum ) From a4cfc897861c8378f5f9b928698700dea102caaf Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Fri, 23 Sep 2016 13:19:57 -0700 Subject: [PATCH 036/491] adjust membrane parameters and add a test case --- src/ProteinLocalizationRestraint.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index c928a601f5..ca2158f95a 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -1286,10 +1286,12 @@ MembraneExclusionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) c IMP_CHECK_OBJECT(sc_.get()); double v = 0; IMP::ParticlesTemp all_particles = sc_->get(); + double excluded_radius = r_ + thickness_; + for (unsigned int i = 0; i < all_particles.size(); ++i ) { core::XYZ i_current = core::XYZ(all_particles[i]); - if ( std::fabs(i_current.get_coordinate(2)) > (r_ + thickness_) ) + if ( std::fabs(i_current.get_coordinate(2)) > excluded_radius ) continue; std::pair dist = half_torus_distance(i_current.get_coordinate(0), From df3e43b65d039d09c381a36a08e6dcf1ab90610b Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Sat, 24 Sep 2016 18:03:40 -0700 Subject: [PATCH 037/491] fixed the half-torus function and cleanup the code --- src/ProteinLocalizationRestraint.cpp | 71 ++++++++++++++++------------ 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index ca2158f95a..0e81232afd 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -1077,33 +1077,37 @@ namespace { std::pair half_torus_distance(double x, double y, double z, double R, double r) { - const double eps = 1e-9; - double d_xy2 = x*x + y*y; - double d_xy = std::sqrt(d_xy2); - double d_tx, d_ty; - double d_txx, d_txy, d_tyy, d_tyx; - if ( d_xy > eps ) - { - d_tx = x - x/d_xy*R; - d_txx = 1 - R*(x*x/d_xy - d_xy)/d_xy2; - d_txy = -R*x*y/(d_xy2*d_xy); - d_ty = y - y/d_xy*R; - d_tyy = 1 - R*(y*y/d_xy - d_xy)/d_xy2; - d_tyx = -R*y*x/(d_xy2*d_xy); - } - else - { - d_tx = x - R; - d_txx = 1; - d_txy = 0; - d_ty = y; - d_tyy = 1; - d_tyx = 0; - } - if ( d_xy <= R ) + double d_xy = std::sqrt(x*x + y*y); + //double d_xy2 = x*x + y*y; + //double d_xy = std::sqrt(d_xy2); + + if ( d_xy < R ) { + const double eps = 1e-9; + double d_tx, d_ty; + //double d_txx, d_txy, d_tyy, d_tyx; + if ( d_xy > eps ) + { + d_tx = x - x/d_xy*R; // x - R * cos(theta) + //d_txx = 1 - R*(x*x/d_xy - d_xy)/d_xy2; + //d_txy = -R*x*y/(d_xy2*d_xy); + d_ty = y - y/d_xy*R; // y - R * sin(theta) + //d_tyy = 1 - R*(y*y/d_xy - d_xy)/d_xy2; + //d_tyx = -R*y*x/(d_xy2*d_xy); + } + else + { + d_tx = x - R; + //d_txx = 1; + //d_txy = 0; + d_ty = y; + //d_tyy = 1; + //d_tyx = 0; + } + double denom = std::sqrt(z*z + d_tx*d_tx + d_ty*d_ty); - algebra::Vector3D der; + algebra::Vector3D der = algebra::Vector3D(0, 0, 0); + /* if ( denom > eps ) { der[0] = (d_tx*d_txx + d_ty*d_tyx)/denom; @@ -1116,13 +1120,16 @@ std::pair half_torus_distance(double x, double y, dou der[1] = (d_tx*d_txy + d_ty*d_tyy)/eps; der[2] = z/eps; } + */ return std::make_pair(denom - r, der); } else { - double dz = z > 0 ? z - r : z + r; - double denom = std::sqrt(dz*dz + d_tx*d_tx + d_ty*d_ty); - algebra::Vector3D der; + double dz = std::abs(z) - r; + //double dz = z > 0 ? z - r : z + r; + //double denom = std::sqrt(dz*dz + d_tx*d_tx + d_ty*d_ty); + algebra::Vector3D der = algebra::Vector3D(0, 0, 0); + /* if ( denom > eps ) { der[0] = -(d_tx*d_txx + d_ty*d_tyx)/denom; @@ -1135,7 +1142,9 @@ std::pair half_torus_distance(double x, double y, dou der[1] = -(d_tx*d_txy + d_ty*d_tyy)/eps; der[2] = dz/eps; } - return std::make_pair(-denom, der); + */ + return std::make_pair(dz, der); + //return std::make_pair(-denom, der); } } } @@ -1213,11 +1222,13 @@ MembraneSurfaceLocationRestraint::unprotected_evaluate(DerivativeAccumulator *ac if ( std::fabs(dist.first) > thickness_ ) { v += dist.first*dist.first; + /* if ( accum ) { all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dist.second*2*dist.first/sigma_, *accum); } + */ } } return v/sigma_; @@ -1299,11 +1310,13 @@ MembraneExclusionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) c if ( dist.first < thickness_ ) { v += (thickness_ - dist.first) * (thickness_ - dist.first); + /* if ( accum ) { all_particles[i]->get_model()->add_to_coordinate_derivatives(IMP::internal::get_index(all_particles[i]), dist.second*2*dist.first/sigma_, *accum); } + */ } } return v/sigma_; From cef511b8bfc2bf8ecb431e1cd0ae79a4826f553c Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Tue, 27 Sep 2016 14:42:47 -0700 Subject: [PATCH 038/491] Add the membrane surface location CONDITIONAL restraint for the potential Nup120 ALPS motifs --- include/ProteinLocalizationRestraint.h | 30 +++++++ pyext/src/npc_restraints.py | 67 ++++++++++++++ src/ProteinLocalizationRestraint.cpp | 119 +++++++++++++++++++++++++ 3 files changed, 216 insertions(+) diff --git a/include/ProteinLocalizationRestraint.h b/include/ProteinLocalizationRestraint.h index cf2b8b989b..f9cc07d85c 100644 --- a/include/ProteinLocalizationRestraint.h +++ b/include/ProteinLocalizationRestraint.h @@ -314,6 +314,36 @@ class IMPNPCEXPORT MembraneSurfaceLocationRestraint : public Restraint }; +class IMPNPCEXPORT MembraneSurfaceLocationConditionalRestraint : public Restraint +{ + IMP::PointerMember sc1_; + IMP::PointerMember sc2_; + double R_; + double r_; + double sigma_; + double thickness_; +public: + MembraneSurfaceLocationConditionalRestraint(Model *m, SingletonContainerAdaptor sc1, SingletonContainerAdaptor sc2, + double R, double r, double thickness, double sigma=2); + MembraneSurfaceLocationConditionalRestraint(Model *m, + double R, double r, double thickness, double sigma=2); + +#ifndef IMP_DOXYGEN + void add_particle1(Particle *p); + void add_particle2(Particle *p); + void add_particles1(const ParticlesTemp &ps); + void add_particles2(const ParticlesTemp &ps); + void set_particles1(const ParticlesTemp &ps); + void set_particles2(const ParticlesTemp &ps); +#endif + + double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const; + ModelObjectsTemp do_get_inputs() const; + + IMP_OBJECT_METHODS(MembraneSurfaceLocationConditionalRestraint);; +}; + + class IMPNPCEXPORT MembraneExclusionRestraint : public Restraint { IMP::PointerMember sc_; diff --git a/pyext/src/npc_restraints.py b/pyext/src/npc_restraints.py index 7df942861c..d270674cc5 100644 --- a/pyext/src/npc_restraints.py +++ b/pyext/src/npc_restraints.py @@ -625,6 +625,73 @@ def evaluate(self): return self.weight * self.rs.unprotected_evaluate(None) +class MembraneSurfaceLocationConditionalRestraint(object): + """Create Membrane Surface Location CONDITIONAL Restraint + for Nup120 ALPS Motifs - Mutually Exclusive from (135,152,'Nup120') and (197,216,'Nup120'). + It returns a minimum penalty score from two potential ALPS motifs. + """ + def __init__(self, + representation = None, + protein1 = None, + protein2 = None, + tor_R = 540.0, + tor_r = 127.5, + tor_th = 45.0, + sigma = 0.2, + resolution = 1, + hier = None): + """Constructor + @param representation representation + """ + + # PMI1/2 selection + if representation is None and hier is not None: + self.m = hier.get_model() + elif hier is None and representation is not None: + self.m = representation.prot.get_model() + else: + raise Exception("MembraneSurfaceLocationConditionalRestraint: must pass hier or representation") + + self.rs = IMP.RestraintSet(self.m, 'MembraneSurfaceLocationConditionalRestraint') + self.weight=1.0 + self.label = "None" + + msl = IMP.npc.MembraneSurfaceLocationConditionalRestraint(self.m, tor_R, tor_r, tor_th, sigma) + residues1 = IMP.pmi.tools.select_by_tuple(representation, protein1, resolution=resolution) + for residue in residues1: + #print (residue, type(residue)) + msl.add_particle1(residue) + residues2 = IMP.pmi.tools.select_by_tuple(representation, protein2, resolution=resolution) + for residue in residues2: + #print (residue, type(residue)) + msl.add_particle2(residue) + self.rs.add_restraint(msl) + + def set_label(self, label): + self.label = label + + def add_to_model(self): + IMP.pmi.tools.add_restraint_to_model(self.m, self.rs) + + def get_restraint(self): + return self.rs + + def set_weight(self, weight): + self.weight = weight + self.rs.set_weight(self.weight) + + def get_output(self): + self.m.update() + output = {} + score = self.weight * self.rs.unprotected_evaluate(None) + output["_TotalScore"] = str(score) + output["MembraneSurfaceLocationConditionalRestraint_" + self.label] = str(score) + return output + + def evaluate(self): + return self.weight * self.rs.unprotected_evaluate(None) + + class MembraneExclusionRestraint(object): """Create Membrane Exclusion Restraint """ diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index 0e81232afd..7a2395d0a2 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -1242,6 +1242,125 @@ ModelObjectsTemp MembraneSurfaceLocationRestraint::do_get_inputs() const { } +/*##################################################### +# Restraints setup - MembraneSurfaceLocationConditionalRestraint +#####################################################*/ +MembraneSurfaceLocationConditionalRestraint::MembraneSurfaceLocationConditionalRestraint(Model *m, + SingletonContainerAdaptor sc1, + SingletonContainerAdaptor sc2, + double R, double r, double thickness, double sigma) + : Restraint(m, "MembraneSurfaceLocationConditionalRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) +{ + sc1_ = sc1; + sc2_ = sc2; +} + +MembraneSurfaceLocationConditionalRestraint::MembraneSurfaceLocationConditionalRestraint(Model *m, + double R, double r, double thickness, double sigma) + : Restraint(m, "MembraneSurfaceLocationConditionalRestraint %1%") + , R_(R) + , r_(r) + , sigma_(sigma) + , thickness_(thickness/2) +{ +} + +void MembraneSurfaceLocationConditionalRestraint::set_particles1(const ParticlesTemp &ps) { + if (!sc1_ && !ps.empty()) { + sc1_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc1_)->set(IMP::internal::get_index(ps)); +} + +void MembraneSurfaceLocationConditionalRestraint::set_particles2(const ParticlesTemp &ps) { + if (!sc2_ && !ps.empty()) { + sc2_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc2_)->set(IMP::internal::get_index(ps)); +} + +void MembraneSurfaceLocationConditionalRestraint::add_particles1(const ParticlesTemp &ps) { + if (!sc1_&& !ps.empty()) { + sc1_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc1_)->add(IMP::internal::get_index(ps)); +} + +void MembraneSurfaceLocationConditionalRestraint::add_particles2(const ParticlesTemp &ps) { + if (!sc2_&& !ps.empty()) { + sc2_ = new IMP::internal::StaticListContainer( + ps[0]->get_model(), "Surface location list"); + } + get_list(sc2_)->add(IMP::internal::get_index(ps)); +} + +void MembraneSurfaceLocationConditionalRestraint::add_particle1(Particle *ps) { + if (!sc1_) { + sc1_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Surface location list"); + } + get_list(sc1_)->add(IMP::internal::get_index(ps)); +} + +void MembraneSurfaceLocationConditionalRestraint::add_particle2(Particle *ps) { + if (!sc2_) { + sc2_ = new IMP::internal::StaticListContainer( + ps->get_model(), "Surface location list"); + } + get_list(sc2_)->add(IMP::internal::get_index(ps)); +} + +double +MembraneSurfaceLocationConditionalRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const +{ + IMP_CHECK_OBJECT(sc1_.get()); + IMP_CHECK_OBJECT(sc2_.get()); + double v1 = 0.0; + IMP::ParticlesTemp all_particles1 = sc1_->get(); + for (unsigned int i = 0; i < all_particles1.size(); ++i ) + { + core::XYZ i_current = core::XYZ(all_particles1[i]); + std::pair dist = half_torus_distance(i_current.get_coordinate(0), + i_current.get_coordinate(1), i_current.get_coordinate(2), R_, r_); + if ( std::fabs(dist.first) > thickness_ ) + { + v1 += dist.first*dist.first; + } + } + double v2 = 0.0; + IMP::ParticlesTemp all_particles2 = sc2_->get(); + for (unsigned int i = 0; i < all_particles2.size(); ++i ) + { + core::XYZ i_current = core::XYZ(all_particles2[i]); + std::pair dist = half_torus_distance(i_current.get_coordinate(0), + i_current.get_coordinate(1), i_current.get_coordinate(2), R_, r_); + if ( std::fabs(dist.first) > thickness_ ) + { + v2 += dist.first*dist.first; + } + } + //printf("v1 = %g\t v2 = %g\t min=%g\n", v1, v2, std::min(v1, v2)); + return std::min(v1, v2)/sigma_; +} + +ModelObjectsTemp MembraneSurfaceLocationConditionalRestraint::do_get_inputs() const { + if ( !sc1_ ) + return ModelObjectsTemp(); + if ( !sc2_ ) + return ModelObjectsTemp(); + ParticleIndexes all = sc1_->get_all_possible_indexes(); + all += sc2_->get_all_possible_indexes(); + return IMP::get_particles(get_model(), all); +} + + /*##################################################### # Restraints setup - MembraneExclusionRestraint #####################################################*/ From 7de18d773f3e68fe7a40b5671ae232ff683f114f Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Sat, 8 Oct 2016 17:26:21 -0700 Subject: [PATCH 039/491] improve performance of the membrane exclusion restraint --- src/ProteinLocalizationRestraint.cpp | 55 +++++++++++++++------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index 7a2395d0a2..ae62b7ac52 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -73,7 +73,7 @@ void ZAxialPositionRestraint::set_particles(const ParticlesTemp &ps) { } void ZAxialPositionRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Z axial list"); } @@ -172,7 +172,7 @@ void ZAxialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { } void ZAxialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Z axial list"); } @@ -256,7 +256,7 @@ void ZAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { } void ZAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Z axial list"); } @@ -342,7 +342,7 @@ void YAxialPositionRestraint::set_particles(const ParticlesTemp &ps) { } void YAxialPositionRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Y axial list"); } @@ -441,7 +441,7 @@ void YAxialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { } void YAxialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Y axial list"); } @@ -525,7 +525,7 @@ void YAxialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { } void YAxialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Y axial list"); } @@ -611,7 +611,7 @@ void XYRadialPositionRestraint::set_particles(const ParticlesTemp &ps) { } void XYRadialPositionRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "XY Radial list"); } @@ -732,7 +732,7 @@ void XYRadialPositionLowerRestraint::set_particles(const ParticlesTemp &ps) { } void XYRadialPositionLowerRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "XY radial list"); } @@ -827,7 +827,7 @@ void XYRadialPositionUpperRestraint::set_particles(const ParticlesTemp &ps) { } void XYRadialPositionUpperRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "XY Radial list"); } @@ -918,7 +918,7 @@ void ProteinContactRestraint::set_particles(const ParticlesTemp &ps) { } void ProteinContactRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein contact list"); } @@ -1011,7 +1011,7 @@ void ProteinChainRestraint::set_particles(const ParticlesTemp &ps) { } void ProteinChainRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein chain list"); } @@ -1184,7 +1184,7 @@ void MembraneSurfaceLocationRestraint::set_particles(const ParticlesTemp &ps) { } void MembraneSurfaceLocationRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } @@ -1286,7 +1286,7 @@ void MembraneSurfaceLocationConditionalRestraint::set_particles2(const Particles } void MembraneSurfaceLocationConditionalRestraint::add_particles1(const ParticlesTemp &ps) { - if (!sc1_&& !ps.empty()) { + if (!sc1_ && !ps.empty()) { sc1_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } @@ -1294,7 +1294,7 @@ void MembraneSurfaceLocationConditionalRestraint::add_particles1(const Particles } void MembraneSurfaceLocationConditionalRestraint::add_particles2(const ParticlesTemp &ps) { - if (!sc2_&& !ps.empty()) { + if (!sc2_ && !ps.empty()) { sc2_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } @@ -1395,7 +1395,7 @@ void MembraneExclusionRestraint::set_particles(const ParticlesTemp &ps) { } void MembraneExclusionRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Membrane exclusion list"); } @@ -1414,18 +1414,23 @@ double MembraneExclusionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { IMP_CHECK_OBJECT(sc_.get()); - double v = 0; + double v = 0.0, x, y, z; + core::XYZ i_current; IMP::ParticlesTemp all_particles = sc_->get(); double excluded_radius = r_ + thickness_; + double membrane_boundary = (R_ - excluded_radius) * (R_ - excluded_radius); for (unsigned int i = 0; i < all_particles.size(); ++i ) { - core::XYZ i_current = core::XYZ(all_particles[i]); - if ( std::fabs(i_current.get_coordinate(2)) > excluded_radius ) + i_current = core::XYZ(all_particles[i]); + x = i_current.get_coordinate(0); + y = i_current.get_coordinate(1); + z = i_current.get_coordinate(2); + + if ( (std::fabs(z) > excluded_radius) || ((x*x + y*y) < membrane_boundary) ) continue; - std::pair dist = half_torus_distance(i_current.get_coordinate(0), - i_current.get_coordinate(1), i_current.get_coordinate(2), R_, r_); + std::pair dist = half_torus_distance(x, y, z, R_, r_); if ( dist.first < thickness_ ) { v += (thickness_ - dist.first) * (thickness_ - dist.first); @@ -1487,7 +1492,7 @@ void PoreSideVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) { } void PoreSideVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } @@ -1579,7 +1584,7 @@ void PerinuclearVolumeLocationRestraint::set_particles(const ParticlesTemp &ps) } void PerinuclearVolumeLocationRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Surface location list"); } @@ -1661,7 +1666,7 @@ void AssemblySymmetryByDistanceRestraint::set_particles(const ParticlesTemp &ps) } void AssemblySymmetryByDistanceRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } @@ -1747,7 +1752,7 @@ void AssemblySymmetryByDihedralRestraint::set_particles(const ParticlesTemp &ps) } void AssemblySymmetryByDihedralRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } @@ -1816,7 +1821,7 @@ void ProteinProximityRestraint::set_particles(const ParticlesTemp &ps) { } void ProteinProximityRestraint::add_particles(const ParticlesTemp &ps) { - if (!sc_&& !ps.empty()) { + if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::StaticListContainer( ps[0]->get_model(), "Protein group configuration list"); } From 175881eee571bfffdec47e0fff693b6ad72911a9 Mon Sep 17 00:00:00 2001 From: "procyon777@gmail.com" Date: Sat, 8 Oct 2016 17:34:18 -0700 Subject: [PATCH 040/491] even further improve the performance of the MembraneExclusionRestraint --- src/ProteinLocalizationRestraint.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index ae62b7ac52..45de299603 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -1427,7 +1427,10 @@ MembraneExclusionRestraint::unprotected_evaluate(DerivativeAccumulator *accum) c y = i_current.get_coordinate(1); z = i_current.get_coordinate(2); - if ( (std::fabs(z) > excluded_radius) || ((x*x + y*y) < membrane_boundary) ) + if ( std::fabs(z) > excluded_radius ) + continue; + + if ( (x*x + y*y) < membrane_boundary ) continue; std::pair dist = half_torus_distance(x, y, z, R_, r_); From c89eae085ce71e2fef9aa224578a7efaab780b69 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 4 Jan 2017 21:13:32 -0800 Subject: [PATCH 041/491] Update copyright year. --- include/CompositeRestraint.h | 2 +- include/MinimumSphereDistancePairScore.h | 2 +- include/ProteinLocalizationRestraint.h | 2 +- src/CompositeRestraint.cpp | 2 +- src/MinimumSphereDistancePairScore.cpp | 2 +- src/ProteinLocalizationRestraint.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/CompositeRestraint.h b/include/CompositeRestraint.h index e0cbb94c5f..b316ce1c51 100644 --- a/include/CompositeRestraint.h +++ b/include/CompositeRestraint.h @@ -1,7 +1,7 @@ /** * \file IMP/npc/CompositeRestraint.h \brief Composite restraint. * - * Copyright 2007-2015 IMP Inventors. All rights reserved. + * Copyright 2007-2017 IMP Inventors. All rights reserved. * */ diff --git a/include/MinimumSphereDistancePairScore.h b/include/MinimumSphereDistancePairScore.h index ec29e92ab1..cde333dd67 100644 --- a/include/MinimumSphereDistancePairScore.h +++ b/include/MinimumSphereDistancePairScore.h @@ -2,7 +2,7 @@ * \file IMP/npc/MinimumSphereDistancePairScore.h * \brief Apply a UnaryFunction to the minimum transformed distance * - * Copyright 2007-2015 IMP Inventors. All rights reserved. + * Copyright 2007-2017 IMP Inventors. All rights reserved. */ #ifndef IMPNPC_MINIMUM_SPHERE_DISTANCE_PAIR_SCORE_H diff --git a/include/ProteinLocalizationRestraint.h b/include/ProteinLocalizationRestraint.h index f9cc07d85c..fe1093f5cf 100644 --- a/include/ProteinLocalizationRestraint.h +++ b/include/ProteinLocalizationRestraint.h @@ -5,7 +5,7 @@ * Restrict max distance between at least one pair of particles of any * two distinct types. It also handles multiple copies of the same particles. * - * Copyright 2007-2015 IMP Inventors. All rights reserved. + * Copyright 2007-2017 IMP Inventors. All rights reserved. * */ diff --git a/src/CompositeRestraint.cpp b/src/CompositeRestraint.cpp index f63c01da44..f287343d5a 100644 --- a/src/CompositeRestraint.cpp +++ b/src/CompositeRestraint.cpp @@ -1,7 +1,7 @@ /** * \file CompositeRestraint.cpp \brief Composite restraint. * - * Copyright 2007-2015 IMP Inventors. All rights reserved. + * Copyright 2007-2017 IMP Inventors. All rights reserved. * */ diff --git a/src/MinimumSphereDistancePairScore.cpp b/src/MinimumSphereDistancePairScore.cpp index f4b755d603..b40684c224 100644 --- a/src/MinimumSphereDistancePairScore.cpp +++ b/src/MinimumSphereDistancePairScore.cpp @@ -2,7 +2,7 @@ * \file MinimumSphereDistancePairScore.cpp * \brief Apply a UnaryFunction to the minimum transformed distance * - * Copyright 2007-2015 IMP Inventors. All rights reserved. + * Copyright 2007-2017 IMP Inventors. All rights reserved. */ #include diff --git a/src/ProteinLocalizationRestraint.cpp b/src/ProteinLocalizationRestraint.cpp index 45de299603..302f78430a 100644 --- a/src/ProteinLocalizationRestraint.cpp +++ b/src/ProteinLocalizationRestraint.cpp @@ -4,7 +4,7 @@ * Restrict max distance between at least one pair of particles of any * two distinct types. * - * Copyright 2007-2015 IMP Inventors. All rights reserved. + * Copyright 2007-2017 IMP Inventors. All rights reserved. * */ From 4f0cf15e8e131c24d503df5b42db163b8e70cbef Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 10 Aug 2017 12:22:03 -0700 Subject: [PATCH 042/491] Use indexes rather than Particles. --- modules/example/include/creating_restraints.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/example/include/creating_restraints.h b/modules/example/include/creating_restraints.h index 9eaddddf9a..a09b730fd4 100644 --- a/modules/example/include/creating_restraints.h +++ b/modules/example/include/creating_restraints.h @@ -48,12 +48,12 @@ inline Restraint *create_chain_restraint(Model *m, /** Create an excluded-volume style ClosePairsContainer based score. */ inline Restraint *create_excluded_volume( - const ParticlesTemp &ps, double k, std::string name) { - IMP_USAGE_CHECK(!ps.empty(), "No Particles passed."); + Model *m, const ParticleIndexes &ps, double k, std::string name) { + IMP_USAGE_CHECK(!ps.empty(), "No ParticleIndexes passed."); //Model *m = ps[0]->get_model(); - double scale = core::XYZR(ps[0]).get_radius(); + double scale = core::XYZR(m, ps[0]).get_radius(); IMP_NEW(container::ListSingletonContainer, cores_container, - (ps, name + " list")); + (m, ps, name + " list")); // Create a close pair container, with a distance bound of 0 and a slack // that is proportional to the particle radius IMP_NEW(container::ClosePairContainer, cpc, (cores_container, 0, scale * .3)); From 7fa64f767fcef237762c3f78666cdc97148afb87 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 10 Aug 2017 12:22:21 -0700 Subject: [PATCH 043/491] Remove functions that were deprecated in 2.7. --- modules/atom/include/Hierarchy.h | 5 ----- modules/atom/src/Hierarchy.cpp | 21 ------------------- modules/core/include/BallMover.h | 9 -------- modules/core/include/ConnectivityRestraint.h | 10 --------- .../core/include/IncrementalScoringFunction.h | 7 ------- modules/core/include/RigidBodyMover.h | 5 ----- modules/core/src/BallMover.cpp | 17 --------------- .../core/src/IncrementalScoringFunction.cpp | 16 -------------- modules/core/src/RigidBodyMover.cpp | 16 -------------- .../GaussianProcessInterpolationRestraint.h | 3 --- .../include/MultivariateFNormalSufficient.h | 3 --- .../GaussianProcessInterpolationRestraint.cpp | 5 ----- .../isd/src/MultivariateFNormalSufficient.cpp | 13 ------------ .../container/ListClassnameContainer.h | 5 ----- .../container/classnames.cpp | 8 ------- 15 files changed, 143 deletions(-) diff --git a/modules/atom/include/Hierarchy.h b/modules/atom/include/Hierarchy.h index 5f4d19083a..ef0fc918c3 100644 --- a/modules/atom/include/Hierarchy.h +++ b/modules/atom/include/Hierarchy.h @@ -437,11 +437,6 @@ IMPATOMEXPORT IMP::core::RigidBody create_rigid_body(Hierarchy h); IMPATOMEXPORT IMP::core::RigidBody create_compatible_rigid_body( Hierarchy h, Hierarchy reference); -#ifndef IMP_DOXYGEN -IMPATOM_DEPRECATED_FUNCTION_DECL(2.7) -IMPATOMEXPORT IMP::core::RigidBody setup_as_rigid_body(Hierarchy h); -#endif - //! Return true if the piece of hierarchy should be classified as a heterogen /** For the purposes of classification, a heterogen is anything that - is a heterogen atom (one whose name starts with HET:) diff --git a/modules/atom/src/Hierarchy.cpp b/modules/atom/src/Hierarchy.cpp index 5cd3c42bfe..d2012832c9 100644 --- a/modules/atom/src/Hierarchy.cpp +++ b/modules/atom/src/Hierarchy.cpp @@ -339,27 +339,6 @@ Bonds get_internal_bonds(Hierarchy mhd) { n=.5*(3*V+2*PI*r^3*f^3-6*PI*r^3*f^2)/((-3*f^2+f^3+2)*r^3*PI) */ -core::RigidBody setup_as_rigid_body(Hierarchy h) { - IMPATOM_DEPRECATED_FUNCTION_DEF(2.7, "Use atom::create_rigid_body instead"); - IMP_USAGE_CHECK(h.get_is_valid(true), - "Invalid hierarchy passed to setup_as_rigid_body"); - core::RigidBody rbd = core::RigidBody::setup_particle(h, get_leaves(h)); - rbd.set_coordinates_are_optimized(true); - ParticlesTemp internal = core::get_internal(h); - for (unsigned int i = 0; i < internal.size(); ++i) { - if (internal[i] != h) { - core::RigidMembers leaves(get_leaves(Hierarchy(internal[i]))); - if (!leaves.empty()) { - algebra::ReferenceFrame3D rf = core::get_initial_reference_frame( - get_as(leaves)); - core::RigidBody::setup_particle(internal[i], rf); - } - } - } - IMP_INTERNAL_CHECK(h.get_is_valid(true), "Invalid hierarchy produced"); - return rbd; -} - namespace { ParticlesTemp rb_process(Hierarchy h) { ParticlesTemp internal = core::get_internal(h); diff --git a/modules/core/include/BallMover.h b/modules/core/include/BallMover.h index 34f5851ae3..e5a5eea995 100644 --- a/modules/core/include/BallMover.h +++ b/modules/core/include/BallMover.h @@ -56,15 +56,6 @@ class IMPCOREEXPORT BallMover : public MonteCarloMover { */ BallMover(Model *m, const ParticleIndexes &pis, Float radius); -#ifndef IMP_DOXYGEN - IMPCORE_DEPRECATED_METHOD_DECL(2.7) - BallMover(const ParticlesTemp &sc, const FloatKeys &vars, - Float radius); - - IMPCORE_DEPRECATED_METHOD_DECL(2.7) - BallMover(const ParticlesTemp &sc, Float radius); -#endif - void set_radius(Float radius) { IMP_ALWAYS_CHECK(radius > 0, "The radius must be positive", IMP::ValueException); diff --git a/modules/core/include/ConnectivityRestraint.h b/modules/core/include/ConnectivityRestraint.h index 868a38a32d..1ca4b78fcf 100644 --- a/modules/core/include/ConnectivityRestraint.h +++ b/modules/core/include/ConnectivityRestraint.h @@ -51,16 +51,6 @@ class IMPCOREEXPORT ConnectivityRestraint : public Restraint { */ ParticleIndexPairs get_connected_index_pairs() const; -#ifndef IMP_DOXYGEN - IMPCORE_DEPRECATED_METHOD_DECL(2.7) - ParticlePairsTemp get_connected_pairs() const { - IMPCORE_DEPRECATED_METHOD_DEF(2.7, - "Use get_connected_index_pairs() instead"); - return IMP::internal::get_particle(get_model(), - get_connected_index_pairs()); - } -#endif - //! Return the pair score used for scoring PairScore *get_pair_score() const { return ps_; } diff --git a/modules/core/include/IncrementalScoringFunction.h b/modules/core/include/IncrementalScoringFunction.h index 6d1f60b2dc..0b4f936ffd 100644 --- a/modules/core/include/IncrementalScoringFunction.h +++ b/modules/core/include/IncrementalScoringFunction.h @@ -94,13 +94,6 @@ class IMPCOREEXPORT IncrementalScoringFunction : public ScoringFunction { std::string name = "IncrementalScoringFunction%1%"); - IMPCORE_DEPRECATED_METHOD_DECL(2.7) - IncrementalScoringFunction(const ParticlesTemp &to_move, - const RestraintsTemp &rs, - double weight = 1.0, double max = NO_MAX, - std::string name = - "IncrementalScoringFunction%1%"); - //! Undo the last moved particles. /** This is similar in effect to, but perhaps more efficient than, calling set_moved_particles() a second time with diff --git a/modules/core/include/RigidBodyMover.h b/modules/core/include/RigidBodyMover.h index 2bb0e24893..7a80d8698b 100644 --- a/modules/core/include/RigidBodyMover.h +++ b/modules/core/include/RigidBodyMover.h @@ -41,11 +41,6 @@ class IMPCOREEXPORT RigidBodyMover : public MonteCarloMover { RigidBodyMover(Model *m, ParticleIndex pi, Float max_translation, Float max_rotation); -#ifndef IMP_DOXYGEN - IMPCORE_DEPRECATED_METHOD_DECL(2.7) - RigidBodyMover(RigidBody d, Float max_translation, Float max_rotation); -#endif - void set_maximum_translation(Float mt) { IMP_USAGE_CHECK(mt > 0, "Max translation must be positive"); max_translation_ = mt; diff --git a/modules/core/src/BallMover.cpp b/modules/core/src/BallMover.cpp index 58de19266c..4a2a568621 100644 --- a/modules/core/src/BallMover.cpp +++ b/modules/core/src/BallMover.cpp @@ -50,23 +50,6 @@ BallMover::BallMover(Model *m, const ParticleIndexes &pis, double radius) initialize(pis, XYZ::get_xyz_keys(), radius); } -// backwards compat -BallMover::BallMover(const ParticlesTemp &sc, const FloatKeys &vars, - double max) - : MonteCarloMover(sc[0]->get_model(), "BallMover%1%") { - IMPCORE_DEPRECATED_METHOD_DEF(2.7, - "Use the index-based constructor instead."); - initialize(get_indexes(sc), vars, max); -} - -// backwards compat -BallMover::BallMover(const ParticlesTemp &sc, double max) - : MonteCarloMover(sc[0]->get_model(), "XYZBallMover%1%") { - IMPCORE_DEPRECATED_METHOD_DEF(2.7, - "Use the index-based constructor instead."); - initialize(get_indexes(sc), XYZ::get_xyz_keys(), max); -} - MonteCarloMoverResult BallMover::do_propose() { IMP_OBJECT_LOG; algebra::SphereKD ball(algebra::get_zero_vector_kd(keys_.size()), radius_); diff --git a/modules/core/src/IncrementalScoringFunction.cpp b/modules/core/src/IncrementalScoringFunction.cpp index 2832dc6e4d..044945e260 100644 --- a/modules/core/src/IncrementalScoringFunction.cpp +++ b/modules/core/src/IncrementalScoringFunction.cpp @@ -47,22 +47,6 @@ IncrementalScoringFunction::IncrementalScoringFunction( flattened_restraints_scores_.resize(flattened_restraints_.size()); } -IncrementalScoringFunction::IncrementalScoringFunction( - const ParticlesTemp &ps, const RestraintsTemp &rs, - double weight, double max, std::string name) - : ScoringFunction(extract_model(ps), name), weight_(weight), max_(max) { - IMPCORE_DEPRECATED_METHOD_DEF(2.7, - "Use the index-based constructor instead."); - IMP_OBJECT_LOG; - IMP_LOG_TERSE("Creating IncrementalScoringFunction with particles " - << ps << " and restraints " << rs << std::endl); - all_ = IMP::internal::get_index(ps); - create_flattened_restraints(rs); - create_scoring_functions(); - dirty_ = all_; - flattened_restraints_scores_.resize(flattened_restraints_.size()); -} - namespace { class IncrementalRestraintsScoringFunction : public IMP::internal::RestraintsScoringFunction { diff --git a/modules/core/src/RigidBodyMover.cpp b/modules/core/src/RigidBodyMover.cpp index 16a7acb598..c7def91520 100644 --- a/modules/core/src/RigidBodyMover.cpp +++ b/modules/core/src/RigidBodyMover.cpp @@ -25,22 +25,6 @@ RigidBodyMover::RigidBodyMover(Model *m, ParticleIndex pi, IMP_LOG_VERBOSE("finish mover construction" << std::endl); } -RigidBodyMover::RigidBodyMover(RigidBody d, Float max_translation, - Float max_angle) - : MonteCarloMover(d->get_model(), d->get_name() + " mover") { - IMPCORE_DEPRECATED_METHOD_DEF(2.7, - "Use the index-based constructor instead."); - IMP_USAGE_CHECK( - d.get_coordinates_are_optimized(), - "Rigid body passed to RigidBodyMover" - << " must be set to be optimized. particle: " << d->get_name()); - IMP_LOG_VERBOSE("start RigidBodyMover constructor"); - max_translation_ = max_translation; - max_angle_ = max_angle; - pi_ = d.get_particle_index(); - IMP_LOG_VERBOSE("finish mover construction" << std::endl); -} - MonteCarloMoverResult RigidBodyMover::do_propose() { IMP_OBJECT_LOG; RigidBody d(get_model(), pi_); diff --git a/modules/isd/include/GaussianProcessInterpolationRestraint.h b/modules/isd/include/GaussianProcessInterpolationRestraint.h index 63b8eb88ec..41d4f1a955 100644 --- a/modules/isd/include/GaussianProcessInterpolationRestraint.h +++ b/modules/isd/include/GaussianProcessInterpolationRestraint.h @@ -54,9 +54,6 @@ class IMPISDEXPORT GaussianProcessInterpolationRestraint calling model.evaluate(False) is enough. */ double get_probability() const { return mvn_->density(); } - IMPISD_DEPRECATED_METHOD_DECL(2.7) - void stats() const; - //! Use conjugate gradients when possible (default false) void set_use_cg(bool use, double tol) { mvn_->set_use_cg(use, tol); } diff --git a/modules/isd/include/MultivariateFNormalSufficient.h b/modules/isd/include/MultivariateFNormalSufficient.h index 9e1d40538a..af073b2254 100644 --- a/modules/isd/include/MultivariateFNormalSufficient.h +++ b/modules/isd/include/MultivariateFNormalSufficient.h @@ -194,9 +194,6 @@ class IMPISDEXPORT MultivariateFNormalSufficient : public Object { //! use conjugate gradients (default false) void set_use_cg(bool use, double tol); - IMPISD_DEPRECATED_METHOD_DECL(2.7) - void stats() const; - //! return Sigma's eigenvalues from smallest to biggest IMP_Eigen::VectorXd get_Sigma_eigenvalues() const; diff --git a/modules/isd/src/GaussianProcessInterpolationRestraint.cpp b/modules/isd/src/GaussianProcessInterpolationRestraint.cpp index 734ccde5bd..8a5448d477 100644 --- a/modules/isd/src/GaussianProcessInterpolationRestraint.cpp +++ b/modules/isd/src/GaussianProcessInterpolationRestraint.cpp @@ -96,11 +96,6 @@ double GaussianProcessInterpolationRestraint::unprotected_evaluate( return ene; } -void GaussianProcessInterpolationRestraint::stats() const { - IMPISD_DEPRECATED_METHOD_DEF(2.7, "Use profiling tools instead"); - mvn_->stats(); -} - double GaussianProcessInterpolationRestraint::get_minus_log_normalization() const { ss_->do_before_evaluate(); diff --git a/modules/isd/src/MultivariateFNormalSufficient.cpp b/modules/isd/src/MultivariateFNormalSufficient.cpp index 085e06033b..fc54abb62e 100644 --- a/modules/isd/src/MultivariateFNormalSufficient.cpp +++ b/modules/isd/src/MultivariateFNormalSufficient.cpp @@ -83,19 +83,6 @@ void MultivariateFNormalSufficient::set_use_cg(bool use, double tol) { if (use) setup_cg(); } -void MultivariateFNormalSufficient::stats() const { - IMPISD_DEPRECATED_METHOD_DEF(2.7, "Use profiling tools instead"); - - static std::string func_displays[IMP_MVN_TIMER_NFUNCS] = { - "eval/density", " trace(WP)", - " get_mean_square_residuals", "deriv_FM", - "deriv_Sigma", " compute_PTP", - " compute_PWP", "Cholesky", - "Sigma*X=B", "compute_PW_direct", - "compute_PW_CG_success"}; - timer_.stats(func_displays); -} - void MultivariateFNormalSufficient::reset_flags() { flag_FM_ = false; flag_FX_ = false; diff --git a/tools/build/container_templates/container/ListClassnameContainer.h b/tools/build/container_templates/container/ListClassnameContainer.h index ae6263bde3..6248dcf25f 100644 --- a/tools/build/container_templates/container/ListClassnameContainer.h +++ b/tools/build/container_templates/container/ListClassnameContainer.h @@ -39,11 +39,6 @@ class IMPCONTAINEREXPORT ListClassnameContainer : ListClassnameContainer(Model *m, const PLURALINDEXTYPE &contents, std::string name = "ListClassnameContainer%1%"); - /** \deprecated_at{2.7} Use the index-based constructor instead */ - IMPCONTAINER_DEPRECATED_METHOD_DECL(2.7) - ListClassnameContainer(const PLURALVARIABLETYPE &ps, - std::string name = "ListClassnameContainer%1%"); - #ifndef IMP_DOXYGEN ListClassnameContainer(Model *m, std::string name = "ListClassnameContainer %1%"); diff --git a/tools/build/container_templates/container/classnames.cpp b/tools/build/container_templates/container/classnames.cpp index f933f65e09..b9ca491ac4 100644 --- a/tools/build/container_templates/container/classnames.cpp +++ b/tools/build/container_templates/container/classnames.cpp @@ -305,14 +305,6 @@ IMPCONTAINER_END_NAMESPACE IMPCONTAINER_BEGIN_NAMESPACE -ListClassnameContainer::ListClassnameContainer(const PLURALVARIABLETYPE &ps, - std::string name) - : P(IMP::internal::get_model(ps[0]), name) { - IMPCONTAINER_DEPRECATED_METHOD_DEF(2.7, - "Use the index-based constructor instead"); - set(IMP::internal::get_index(ps)); -} - ListClassnameContainer::ListClassnameContainer(Model *m, const PLURALINDEXTYPE &ps, std::string name) From 4c06137253f1b8ae1524f552b9ce0891ed5b3e4a Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 11 Aug 2017 08:34:09 -0700 Subject: [PATCH 044/491] Remove unused function. --- modules/core/src/IncrementalScoringFunction.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules/core/src/IncrementalScoringFunction.cpp b/modules/core/src/IncrementalScoringFunction.cpp index 044945e260..0cb5f0e6c0 100644 --- a/modules/core/src/IncrementalScoringFunction.cpp +++ b/modules/core/src/IncrementalScoringFunction.cpp @@ -24,15 +24,6 @@ IMPCORE_BEGIN_NAMESPACE restraint set that return 0 or inf if the last scores for the set are bad.*/ -namespace { -// TODO: this can be made a general library function at some point -IMP::Model *extract_model(const ParticlesTemp &ps) { - IMP_USAGE_CHECK(ps.size() > 0, - "needs at least one particle to extract a model"); - return ps[0]->get_model(); -} -} - IncrementalScoringFunction::IncrementalScoringFunction( Model *m, const ParticleIndexes &ps, const RestraintsTemp &rs, double weight, double max, std::string name) From f83a1be9b8749d77d3420019395e688c0f1031ed Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 11 Aug 2017 08:34:24 -0700 Subject: [PATCH 045/491] Use indexes rather than Particles. --- modules/container/test/test_create_restraint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/container/test/test_create_restraint.py b/modules/container/test/test_create_restraint.py index 045f7a9bce..cb3f201dab 100644 --- a/modules/container/test/test_create_restraint.py +++ b/modules/container/test/test_create_restraint.py @@ -2,9 +2,9 @@ import IMP.container m = IMP.Model() -p0 = IMP.Particle(m) -p1 = IMP.Particle(m) +p0 = m.add_particle("P0") +p1 = m.add_particle("P1") ps = IMP.core.SoftSpherePairScore(1) cr = IMP.container.create_restraint( - ps, IMP.container.ListPairContainer([(p0, p1)])) + ps, IMP.container.ListPairContainer(m, [(p0, p1)])) From 09df06e054a206db791f9e7cb896788eb6466cdb Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 11 Aug 2017 08:36:33 -0700 Subject: [PATCH 046/491] Use new index-based constructor. --- modules/core/test/expensive_test_mc_rigid.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/core/test/expensive_test_mc_rigid.py b/modules/core/test/expensive_test_mc_rigid.py index b04b48ac4a..1a106a8ecc 100644 --- a/modules/core/test/expensive_test_mc_rigid.py +++ b/modules/core/test/expensive_test_mc_rigid.py @@ -63,9 +63,11 @@ def test_c1(self): opt = IMP.core.MonteCarloWithLocalOptimization(lopt, 100) opt.set_scoring_function(self.sf) lopt.set_scoring_function(self.sf) - mover1 = IMP.core.RigidBodyMover(IMP.core.RigidBody(self.rb0), 5., 15.) + mover1 = IMP.core.RigidBodyMover(self.m, IMP.core.RigidBody(self.rb0), + 5., 15.) opt.add_mover(mover1) - mover2 = IMP.core.RigidBodyMover(IMP.core.RigidBody(self.rb1), 5., 15.) + mover2 = IMP.core.RigidBodyMover(self.m, IMP.core.RigidBody(self.rb1), + 5., 15.) opt.add_mover(mover2) opt.set_score_threshold(.001) for i in range(0, 5): From a8ef53c67d52b4dac99be62b440d0895a08613d2 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 11 Aug 2017 12:31:47 -0700 Subject: [PATCH 047/491] Don't use 'typename' outside of a template. While newer gcc will accept this usage, the old gcc that we use to build conda packages doesn't like it. --- modules/cgal/test/test_memory_problem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cgal/test/test_memory_problem.cpp b/modules/cgal/test/test_memory_problem.cpp index ece0b22115..7d61733a73 100644 --- a/modules/cgal/test/test_memory_problem.cpp +++ b/modules/cgal/test/test_memory_problem.cpp @@ -30,7 +30,7 @@ typedef CGAL::Fixed_alpha_shape_cell_base_3 Fb; typedef CGAL::Triangulation_data_structure_3 TDS; typedef CGAL::Regular_triangulation_3 Triangulation; #if CGAL_VERSION_NR > 1040911000 -typedef typename Gt::Point_3 Wpoint; +typedef Gt::Point_3 Wpoint; #else typedef Gt::Point Wpoint; #endif From 83dd1ea51c351eace4da5f35832cdee8a9a666a9 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Mon, 14 Aug 2017 10:01:42 -0700 Subject: [PATCH 048/491] Start working on next release. --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 560b17c466..a4c29712ee 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,8 @@ ChangeLog {#changelog} ========= +# HEAD + # 2.8.0 - 2017-08-16 # {#changelog_2_8_0} - New applications of IMP are now available: - [Modeling of the yeast Spindle Pole Body core](https://salilab.org/spb/) From 1995ff7bce21279d4c34ec028a2c7ce5c7bb9a75 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 16 Aug 2017 10:23:32 -0700 Subject: [PATCH 049/491] Suppress 'was not used' warning. Since we do "use" these objects, we should set the was-used flag, otherwise we'll get a warning on every single score evaluation. --- modules/isd/src/AmbiguousNOERestraint.cpp | 2 +- modules/isd/src/GaussianRestraint.cpp | 1 - modules/isd/src/LognormalRestraint.cpp | 2 +- modules/isd/src/NOERestraint.cpp | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/isd/src/AmbiguousNOERestraint.cpp b/modules/isd/src/AmbiguousNOERestraint.cpp index 1192028ffb..9e31e90a5b 100644 --- a/modules/isd/src/AmbiguousNOERestraint.cpp +++ b/modules/isd/src/AmbiguousNOERestraint.cpp @@ -61,7 +61,7 @@ double AmbiguousNOERestraint::unprotected_evaluate(DerivativeAccumulator *accum) double FM = log(Icalc); double JA = 1.0 / Vexp_; IMP_NEW(FNormal, lognormal, (FA, JA, FM, sigma_val)); - // lognormal->set_was_used(true); // get rid of warning + lognormal->set_was_used(true); /* get score */ double score = lognormal->evaluate(); const_cast(this)->set_chi(FA - FM); diff --git a/modules/isd/src/GaussianRestraint.cpp b/modules/isd/src/GaussianRestraint.cpp index c0b7f7cf2a..1ae930847e 100644 --- a/modules/isd/src/GaussianRestraint.cpp +++ b/modules/isd/src/GaussianRestraint.cpp @@ -127,7 +127,6 @@ double GaussianRestraint::unprotected_evaluate(DerivativeAccumulator *accum) double JA = 1.0; IMP_NEW(FNormal, normal, (x, JA, mu, sigma)); normal->set_was_used(true); - // normal->set_was_used(true); // get rid of warning /* get score */ double score = normal->evaluate(); const_cast(this)->set_chi(x - mu); diff --git a/modules/isd/src/LognormalRestraint.cpp b/modules/isd/src/LognormalRestraint.cpp index cb6f2ae915..7e03182e86 100644 --- a/modules/isd/src/LognormalRestraint.cpp +++ b/modules/isd/src/LognormalRestraint.cpp @@ -130,7 +130,7 @@ double LognormalRestraint::unprotected_evaluate(DerivativeAccumulator *accum) double lx = log(x); double lmu = log(mu); IMP_NEW(FNormal, normal, (lx, JA, lmu, sigma)); - // normal->set_was_used(true); // get rid of warning + normal->set_was_used(true); /* get score */ double score = normal->evaluate(); const_cast(this)->set_chi(lx - lmu); diff --git a/modules/isd/src/NOERestraint.cpp b/modules/isd/src/NOERestraint.cpp index aa42b25893..8ae58b7199 100644 --- a/modules/isd/src/NOERestraint.cpp +++ b/modules/isd/src/NOERestraint.cpp @@ -44,7 +44,7 @@ double NOERestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { double FM = log(Icalc); double JA = 1.0 / Vexp_; IMP_NEW(FNormal, lognormal, (FA, JA, FM, sigma_val)); - // lognormal->set_was_used(true); // get rid of warning + lognormal->set_was_used(true); /* get score */ double score = lognormal->evaluate(); const_cast(this)->set_chi(FA - FM); From 8ab3a03b5e11e93bcba016728caf79bc6c48b8e7 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 16 Aug 2017 14:15:27 -0700 Subject: [PATCH 050/491] Add more on big files and modified inputs. --- doc/manual/biosystem.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/manual/biosystem.md b/doc/manual/biosystem.md index 76c3048059..c428f2d3d3 100644 --- a/doc/manual/biosystem.md +++ b/doc/manual/biosystem.md @@ -23,13 +23,19 @@ We recommend the following contents for your repository (see the for an example): - subdirectories containing - - your modeling protocol (generally one or more Python scripts) + - your modeling protocol (generally one or more Python scripts). - input files (e.g. PDB files, EM density maps, lists of crosslinks), - especially if these files aren't in a database somewhere already + especially if these files aren't in a database somewhere already. + If these inputs are derived in some fashion (e.g. you use a PDB file as + input that's a comparative model or docking result, or you use an EM map + that's been segmented) then this needs to be described somewhere, with + links to the original unmodified files (e.g. PDB IDs for templates of any + comparative models, alignment files, Modeller scripts). - outputs (trajectories, clusters, analysis). Where this isn't possible due to size, we can host the larger files, such as trajectories, elsewhere (e.g. as a dataset in [Zenodo](https://zenodo.org)) and link to them - from the repository. + from the repository. Aim to keep the repository below 1GB in size so that + it's manageable. - a top-level `%README.md` file describing the system and explaining how to run the protocol. - a top-level `LICENSE` file with the license for the data files and scripts. From f2f8010c61e403759d5dae3e09a971213b56efe8 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 16 Aug 2017 15:38:02 -0700 Subject: [PATCH 051/491] Allow for rounding error in cluster weights. While the minimum weight should be zero, it may be very slightly less (say -1e-15) due to rounding error. --- modules/spb/src/DistanceRMSDMetric.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/spb/src/DistanceRMSDMetric.cpp b/modules/spb/src/DistanceRMSDMetric.cpp index 8b4ff0b925..c6bc823946 100644 --- a/modules/spb/src/DistanceRMSDMetric.cpp +++ b/modules/spb/src/DistanceRMSDMetric.cpp @@ -207,7 +207,9 @@ statistics::PartitionalClustering *create_gromos_clustering( } // no more clusters to find - if (maxweight < 0.) { + // note that while the minimum weight should be zero, it may be very + // slightly less (say -1e-15) due to rounding error + if (maxweight < -0.01) { break; } From df87ff0f2647e44ecc0733ab8a5c8c80b6882180 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 16 Aug 2017 23:29:39 -0700 Subject: [PATCH 052/491] Require system Eigen. Add Eigen as a dependency rather than bundling a copy. This allows us to easily use the latest version of Eigen, getting any upstream fixes, without having to hack the headers to put everything in a unique namespace and to suppress compiler warnings. Additionally, it allows us to use certain CGAL features which rely on system Eigen being present. Relates #904. --- CMakeLists.txt | 3 +++ doc/manual/installation.md | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 561fbdf909..82ada4d4d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,6 +277,9 @@ if(NOT IMP_STATIC) find_package(OpenMP3) endif() +find_package(Eigen3 3.0 REQUIRED) +include_directories(${EIGEN3_INCLUDE_DIR}) + add_custom_target("IMP-version" COMMAND ${CMAKE_SOURCE_DIR}/tools/build/make_version.py --source=${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/doc/manual/installation.md b/doc/manual/installation.md index cecbacf6c3..0d66d9d4be 100644 --- a/doc/manual/installation.md +++ b/doc/manual/installation.md @@ -24,6 +24,7 @@ In order to build %IMP from source, you will need: - [CMake](https://cmake.org) (2.8 or later) - [Boost](http://www.boost.org) (1.41 or later) +- [Eigen](https://eigen.tuxfamily.org/) (3.0 or later) - [HDF5](https://support.hdfgroup.org/HDF5/) (1.8 or later; 1.10 should also work) - [Python](https://www.python.org) (2.6 or later, or any version of Python 3) @@ -80,7 +81,7 @@ such as brew tap homebrew/science brew tap salilab/salilab - brew install boost gmp google-perftools cgal graphviz gsl cmake doxygen hdf5 swig fftw mpfr opencv libtau + brew install boost gmp google-perftools cgal graphviz gsl cmake doxygen hdf5 swig fftw mpfr opencv libtau eigen to install everything %IMP finds useful (or that you will want for installing various useful Python libs that %IMP finds useful). On older Macs, you may also need to `brew install git` if you want to use git (newer Macs include git). - [Macports](http://www.macports.org/) If you use MacPorts, you must add `/opt/local/bin` to your path (either by modifying your shell's From 5891e10537eb2f8fd376ff8effcc3459590083fb Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 16 Aug 2017 23:37:17 -0700 Subject: [PATCH 053/491] Remove bundled copy of Eigen. Since we now require a system copy of Eigen, we no longer need to bundle another one. --- modules/algebra/include/eigen3/Eigen/Array | 11 - modules/algebra/include/eigen3/Eigen/Cholesky | 32 - .../include/eigen3/Eigen/CholmodSupport | 45 - modules/algebra/include/eigen3/Eigen/Core | 376 ---- modules/algebra/include/eigen3/Eigen/Dense | 7 - modules/algebra/include/eigen3/Eigen/Eigen | 2 - .../include/eigen3/Eigen/Eigen2Support | 95 - .../algebra/include/eigen3/Eigen/Eigenvalues | 48 - modules/algebra/include/eigen3/Eigen/Geometry | 63 - .../algebra/include/eigen3/Eigen/Householder | 23 - .../eigen3/Eigen/IterativeLinearSolvers | 40 - modules/algebra/include/eigen3/Eigen/Jacobi | 26 - modules/algebra/include/eigen3/Eigen/LU | 41 - .../algebra/include/eigen3/Eigen/LeastSquares | 32 - .../algebra/include/eigen3/Eigen/MetisSupport | 28 - .../include/eigen3/Eigen/OrderingMethods | 66 - .../include/eigen3/Eigen/PaStiXSupport | 46 - .../include/eigen3/Eigen/PardisoSupport | 30 - modules/algebra/include/eigen3/Eigen/QR | 45 - .../include/eigen3/Eigen/QtAlignedMalloc | 34 - .../algebra/include/eigen3/Eigen/SPQRSupport | 29 - modules/algebra/include/eigen3/Eigen/SVD | 37 - modules/algebra/include/eigen3/Eigen/Sparse | 27 - .../include/eigen3/Eigen/SparseCholesky | 47 - .../algebra/include/eigen3/Eigen/SparseCore | 64 - modules/algebra/include/eigen3/Eigen/SparseLU | 49 - modules/algebra/include/eigen3/Eigen/SparseQR | 33 - modules/algebra/include/eigen3/Eigen/StdDeque | 27 - modules/algebra/include/eigen3/Eigen/StdList | 26 - .../algebra/include/eigen3/Eigen/StdVector | 27 - .../include/eigen3/Eigen/SuperLUSupport | 59 - .../include/eigen3/Eigen/UmfPackSupport | 36 - .../include/eigen3/Eigen/src/Cholesky/LDLT.h | 611 ------ .../include/eigen3/Eigen/src/Cholesky/LLT.h | 498 ----- .../eigen3/Eigen/src/Cholesky/LLT_MKL.h | 102 - .../Eigen/src/CholmodSupport/CholmodSupport.h | 607 ------ .../include/eigen3/Eigen/src/Core/Array.h | 323 --- .../include/eigen3/Eigen/src/Core/ArrayBase.h | 226 -- .../eigen3/Eigen/src/Core/ArrayWrapper.h | 264 --- .../include/eigen3/Eigen/src/Core/Assign.h | 590 ------ .../eigen3/Eigen/src/Core/Assign_MKL.h | 224 -- .../eigen3/Eigen/src/Core/BandMatrix.h | 334 --- .../include/eigen3/Eigen/src/Core/Block.h | 406 ---- .../eigen3/Eigen/src/Core/BooleanRedux.h | 154 -- .../eigen3/Eigen/src/Core/CommaInitializer.h | 157 -- .../eigen3/Eigen/src/Core/CoreIterators.h | 61 - .../eigen3/Eigen/src/Core/CwiseBinaryOp.h | 230 -- .../eigen3/Eigen/src/Core/CwiseNullaryOp.h | 864 -------- .../eigen3/Eigen/src/Core/CwiseUnaryOp.h | 126 -- .../eigen3/Eigen/src/Core/CwiseUnaryView.h | 139 -- .../include/eigen3/Eigen/src/Core/DenseBase.h | 521 ----- .../eigen3/Eigen/src/Core/DenseCoeffsBase.h | 754 ------- .../eigen3/Eigen/src/Core/DenseStorage.h | 434 ---- .../include/eigen3/Eigen/src/Core/Diagonal.h | 237 --- .../eigen3/Eigen/src/Core/DiagonalMatrix.h | 313 --- .../eigen3/Eigen/src/Core/DiagonalProduct.h | 131 -- .../include/eigen3/Eigen/src/Core/Dot.h | 263 --- .../include/eigen3/Eigen/src/Core/EigenBase.h | 131 -- .../include/eigen3/Eigen/src/Core/Flagged.h | 140 -- .../Eigen/src/Core/ForceAlignedAccess.h | 146 -- .../include/eigen3/Eigen/src/Core/Functors.h | 1029 --------- .../include/eigen3/Eigen/src/Core/Fuzzy.h | 150 -- .../eigen3/Eigen/src/Core/GeneralProduct.h | 633 ------ .../eigen3/Eigen/src/Core/GenericPacketMath.h | 350 ---- .../eigen3/Eigen/src/Core/GlobalFunctions.h | 92 - .../include/eigen3/Eigen/src/Core/IO.h | 250 --- .../include/eigen3/Eigen/src/Core/Map.h | 192 -- .../include/eigen3/Eigen/src/Core/MapBase.h | 251 --- .../eigen3/Eigen/src/Core/MathFunctions.h | 779 ------- .../include/eigen3/Eigen/src/Core/Matrix.h | 420 ---- .../eigen3/Eigen/src/Core/MatrixBase.h | 563 ----- .../eigen3/Eigen/src/Core/NestByValue.h | 111 - .../include/eigen3/Eigen/src/Core/NoAlias.h | 134 -- .../include/eigen3/Eigen/src/Core/NumTraits.h | 150 -- .../eigen3/Eigen/src/Core/PermutationMatrix.h | 722 ------- .../eigen3/Eigen/src/Core/PlainObjectBase.h | 822 -------- .../eigen3/Eigen/src/Core/ProductBase.h | 290 --- .../include/eigen3/Eigen/src/Core/Random.h | 152 -- .../include/eigen3/Eigen/src/Core/Redux.h | 409 ---- .../include/eigen3/Eigen/src/Core/Ref.h | 278 --- .../include/eigen3/Eigen/src/Core/Replicate.h | 177 -- .../eigen3/Eigen/src/Core/ReturnByValue.h | 99 - .../include/eigen3/Eigen/src/Core/Reverse.h | 224 -- .../include/eigen3/Eigen/src/Core/Select.h | 162 -- .../eigen3/Eigen/src/Core/SelfAdjointView.h | 314 --- .../eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h | 191 -- .../eigen3/Eigen/src/Core/SolveTriangular.h | 261 --- .../eigen3/Eigen/src/Core/StableNorm.h | 203 -- .../include/eigen3/Eigen/src/Core/Stride.h | 108 - .../include/eigen3/Eigen/src/Core/Swap.h | 126 -- .../include/eigen3/Eigen/src/Core/Transpose.h | 418 ---- .../eigen3/Eigen/src/Core/Transpositions.h | 437 ---- .../eigen3/Eigen/src/Core/TriangularMatrix.h | 839 -------- .../eigen3/Eigen/src/Core/VectorBlock.h | 95 - .../eigen3/Eigen/src/Core/VectorwiseOp.h | 642 ------ .../include/eigen3/Eigen/src/Core/Visitor.h | 240 --- .../Eigen/src/Core/arch/AltiVec/Complex.h | 217 -- .../Eigen/src/Core/arch/AltiVec/PacketMath.h | 501 ----- .../Eigen/src/Core/arch/Default/Settings.h | 49 - .../eigen3/Eigen/src/Core/arch/NEON/Complex.h | 253 --- .../Eigen/src/Core/arch/NEON/PacketMath.h | 420 ---- .../eigen3/Eigen/src/Core/arch/SSE/Complex.h | 442 ---- .../Eigen/src/Core/arch/SSE/MathFunctions.h | 475 ----- .../Eigen/src/Core/arch/SSE/PacketMath.h | 613 ------ .../src/Core/products/CoeffBasedProduct.h | 476 ----- .../Core/products/GeneralBlockPanelKernel.h | 1341 ------------ .../src/Core/products/GeneralMatrixMatrix.h | 433 ---- .../products/GeneralMatrixMatrixTriangular.h | 278 --- .../GeneralMatrixMatrixTriangular_MKL.h | 146 -- .../Core/products/GeneralMatrixMatrix_MKL.h | 118 -- .../src/Core/products/GeneralMatrixVector.h | 566 ----- .../Core/products/GeneralMatrixVector_MKL.h | 131 -- .../Eigen/src/Core/products/Parallelizer.h | 162 -- .../Core/products/SelfadjointMatrixMatrix.h | 436 ---- .../products/SelfadjointMatrixMatrix_MKL.h | 295 --- .../Core/products/SelfadjointMatrixVector.h | 281 --- .../products/SelfadjointMatrixVector_MKL.h | 114 - .../src/Core/products/SelfadjointProduct.h | 123 -- .../Core/products/SelfadjointRank2Update.h | 93 - .../Core/products/TriangularMatrixMatrix.h | 427 ---- .../products/TriangularMatrixMatrix_MKL.h | 309 --- .../Core/products/TriangularMatrixVector.h | 348 ---- .../products/TriangularMatrixVector_MKL.h | 247 --- .../Core/products/TriangularSolverMatrix.h | 332 --- .../products/TriangularSolverMatrix_MKL.h | 155 -- .../Core/products/TriangularSolverVector.h | 139 -- .../eigen3/Eigen/src/Core/util/BlasUtil.h | 268 --- .../eigen3/Eigen/src/Core/util/Constants.h | 451 ---- .../src/Core/util/DisableStupidWarnings.h | 52 - .../Eigen/src/Core/util/ForwardDeclarations.h | 302 --- .../eigen3/Eigen/src/Core/util/MKL_support.h | 158 -- .../eigen3/Eigen/src/Core/util/Macros.h | 714 ------- .../eigen3/Eigen/src/Core/util/Memory.h | 944 --------- .../include/eigen3/Eigen/src/Core/util/Meta.h | 243 --- .../eigen3/Eigen/src/Core/util/NonMPL2.h | 3 - .../src/Core/util/ReenableStupidWarnings.h | 17 - .../eigen3/Eigen/src/Core/util/StaticAssert.h | 208 -- .../eigen3/Eigen/src/Core/util/XprHelper.h | 469 ----- .../eigen3/Eigen/src/Eigen2Support/Block.h | 126 -- .../eigen3/Eigen/src/Eigen2Support/Cwise.h | 192 -- .../Eigen/src/Eigen2Support/CwiseOperators.h | 298 --- .../src/Eigen2Support/Geometry/AlignedBox.h | 159 -- .../Eigen/src/Eigen2Support/Geometry/All.h | 115 - .../src/Eigen2Support/Geometry/AngleAxis.h | 214 -- .../src/Eigen2Support/Geometry/Hyperplane.h | 254 --- .../Eigen2Support/Geometry/ParametrizedLine.h | 141 -- .../src/Eigen2Support/Geometry/Quaternion.h | 495 ----- .../src/Eigen2Support/Geometry/Rotation2D.h | 145 -- .../src/Eigen2Support/Geometry/RotationBase.h | 123 -- .../src/Eigen2Support/Geometry/Scaling.h | 167 -- .../src/Eigen2Support/Geometry/Transform.h | 786 ------- .../src/Eigen2Support/Geometry/Translation.h | 184 -- .../eigen3/Eigen/src/Eigen2Support/LU.h | 120 -- .../eigen3/Eigen/src/Eigen2Support/Lazy.h | 71 - .../Eigen/src/Eigen2Support/LeastSquares.h | 169 -- .../eigen3/Eigen/src/Eigen2Support/Macros.h | 20 - .../Eigen/src/Eigen2Support/MathFunctions.h | 57 - .../eigen3/Eigen/src/Eigen2Support/Memory.h | 45 - .../eigen3/Eigen/src/Eigen2Support/Meta.h | 75 - .../eigen3/Eigen/src/Eigen2Support/Minor.h | 117 -- .../eigen3/Eigen/src/Eigen2Support/QR.h | 67 - .../eigen3/Eigen/src/Eigen2Support/SVD.h | 637 ------ .../src/Eigen2Support/TriangularSolver.h | 42 - .../Eigen/src/Eigen2Support/VectorBlock.h | 94 - .../src/Eigenvalues/ComplexEigenSolver.h | 341 --- .../Eigen/src/Eigenvalues/ComplexSchur.h | 456 ---- .../Eigen/src/Eigenvalues/ComplexSchur_MKL.h | 93 - .../Eigen/src/Eigenvalues/EigenSolver.h | 607 ------ .../src/Eigenvalues/GeneralizedEigenSolver.h | 370 ---- .../GeneralizedSelfAdjointEigenSolver.h | 227 -- .../src/Eigenvalues/HessenbergDecomposition.h | 373 ---- .../src/Eigenvalues/MatrixBaseEigenvalues.h | 160 -- .../eigen3/Eigen/src/Eigenvalues/RealQZ.h | 624 ------ .../eigen3/Eigen/src/Eigenvalues/RealSchur.h | 525 ----- .../Eigen/src/Eigenvalues/RealSchur_MKL.h | 79 - .../src/Eigenvalues/SelfAdjointEigenSolver.h | 801 ------- .../Eigenvalues/SelfAdjointEigenSolver_MKL.h | 92 - .../src/Eigenvalues/Tridiagonalization.h | 557 ----- .../eigen3/Eigen/src/Geometry/AlignedBox.h | 392 ---- .../eigen3/Eigen/src/Geometry/AngleAxis.h | 240 --- .../eigen3/Eigen/src/Geometry/EulerAngles.h | 104 - .../eigen3/Eigen/src/Geometry/Homogeneous.h | 307 --- .../eigen3/Eigen/src/Geometry/Hyperplane.h | 280 --- .../eigen3/Eigen/src/Geometry/OrthoMethods.h | 218 -- .../Eigen/src/Geometry/ParametrizedLine.h | 195 -- .../eigen3/Eigen/src/Geometry/Quaternion.h | 776 ------- .../eigen3/Eigen/src/Geometry/Rotation2D.h | 160 -- .../eigen3/Eigen/src/Geometry/RotationBase.h | 206 -- .../eigen3/Eigen/src/Geometry/Scaling.h | 166 -- .../eigen3/Eigen/src/Geometry/Transform.h | 1474 ------------- .../eigen3/Eigen/src/Geometry/Translation.h | 206 -- .../eigen3/Eigen/src/Geometry/Umeyama.h | 177 -- .../Eigen/src/Geometry/arch/Geometry_SSE.h | 115 - .../Eigen/src/Householder/BlockHouseholder.h | 68 - .../Eigen/src/Householder/Householder.h | 172 -- .../src/Householder/HouseholderSequence.h | 442 ---- .../BasicPreconditioners.h | 149 -- .../src/IterativeLinearSolvers/BiCGSTAB.h | 263 --- .../ConjugateGradient.h | 258 --- .../IterativeLinearSolvers/IncompleteLUT.h | 478 ----- .../IterativeSolverBase.h | 282 --- .../include/eigen3/Eigen/src/Jacobi/Jacobi.h | 433 ---- .../include/eigen3/Eigen/src/LU/Determinant.h | 101 - .../include/eigen3/Eigen/src/LU/FullPivLU.h | 751 ------- .../include/eigen3/Eigen/src/LU/Inverse.h | 400 ---- .../eigen3/Eigen/src/LU/PartialPivLU.h | 509 ----- .../eigen3/Eigen/src/LU/PartialPivLU_MKL.h | 85 - .../eigen3/Eigen/src/LU/arch/Inverse_SSE.h | 329 --- .../Eigen/src/MetisSupport/MetisSupport.h | 137 -- .../eigen3/Eigen/src/OrderingMethods/Amd.h | 444 ---- .../Eigen/src/OrderingMethods/Eigen_Colamd.h | 1843 ----------------- .../Eigen/src/OrderingMethods/Ordering.h | 154 -- .../Eigen/src/PaStiXSupport/PaStiXSupport.h | 729 ------- .../Eigen/src/PardisoSupport/PardisoSupport.h | 603 ------ .../eigen3/Eigen/src/QR/ColPivHouseholderQR.h | 580 ------ .../Eigen/src/QR/ColPivHouseholderQR_MKL.h | 98 - .../Eigen/src/QR/FullPivHouseholderQR.h | 622 ------ .../eigen3/Eigen/src/QR/HouseholderQR.h | 388 ---- .../eigen3/Eigen/src/QR/HouseholderQR_MKL.h | 71 - .../src/SPQRSupport/SuiteSparseQRSupport.h | 338 --- .../include/eigen3/Eigen/src/SVD/JacobiSVD.h | 1000 --------- .../eigen3/Eigen/src/SVD/JacobiSVD_MKL.h | 92 - .../Eigen/src/SVD/UpperBidiagonalization.h | 148 -- .../src/SparseCholesky/SimplicialCholesky.h | 671 ------ .../SparseCholesky/SimplicialCholesky_impl.h | 199 -- .../eigen3/Eigen/src/SparseCore/AmbiVector.h | 373 ---- .../Eigen/src/SparseCore/CompressedStorage.h | 240 --- .../ConservativeSparseSparseProduct.h | 245 --- .../Eigen/src/SparseCore/MappedSparseMatrix.h | 181 -- .../eigen3/Eigen/src/SparseCore/SparseBlock.h | 538 ----- .../Eigen/src/SparseCore/SparseColEtree.h | 206 -- .../src/SparseCore/SparseCwiseBinaryOp.h | 324 --- .../Eigen/src/SparseCore/SparseCwiseUnaryOp.h | 163 -- .../Eigen/src/SparseCore/SparseDenseProduct.h | 311 --- .../src/SparseCore/SparseDiagonalProduct.h | 196 -- .../eigen3/Eigen/src/SparseCore/SparseDot.h | 101 - .../eigen3/Eigen/src/SparseCore/SparseFuzzy.h | 26 - .../Eigen/src/SparseCore/SparseMatrix.h | 1262 ----------- .../Eigen/src/SparseCore/SparseMatrixBase.h | 462 ----- .../Eigen/src/SparseCore/SparsePermutation.h | 148 -- .../Eigen/src/SparseCore/SparseProduct.h | 188 -- .../eigen3/Eigen/src/SparseCore/SparseRedux.h | 48 - .../src/SparseCore/SparseSelfAdjointView.h | 507 ----- .../SparseSparseProductWithPruning.h | 150 -- .../Eigen/src/SparseCore/SparseTranspose.h | 63 - .../src/SparseCore/SparseTriangularView.h | 179 -- .../eigen3/Eigen/src/SparseCore/SparseUtil.h | 172 -- .../Eigen/src/SparseCore/SparseVector.h | 448 ---- .../eigen3/Eigen/src/SparseCore/SparseView.h | 99 - .../Eigen/src/SparseCore/TriangularSolver.h | 334 --- .../eigen3/Eigen/src/SparseLU/SparseLU.h | 806 ------- .../eigen3/Eigen/src/SparseLU/SparseLUImpl.h | 66 - .../Eigen/src/SparseLU/SparseLU_Memory.h | 227 -- .../Eigen/src/SparseLU/SparseLU_Structs.h | 111 - .../src/SparseLU/SparseLU_SupernodalMatrix.h | 298 --- .../Eigen/src/SparseLU/SparseLU_Utils.h | 80 - .../Eigen/src/SparseLU/SparseLU_column_bmod.h | 180 -- .../Eigen/src/SparseLU/SparseLU_column_dfs.h | 177 -- .../src/SparseLU/SparseLU_copy_to_ucol.h | 106 - .../Eigen/src/SparseLU/SparseLU_gemm_kernel.h | 279 --- .../src/SparseLU/SparseLU_heap_relax_snode.h | 127 -- .../Eigen/src/SparseLU/SparseLU_kernel_bmod.h | 130 -- .../Eigen/src/SparseLU/SparseLU_panel_bmod.h | 223 -- .../Eigen/src/SparseLU/SparseLU_panel_dfs.h | 258 --- .../Eigen/src/SparseLU/SparseLU_pivotL.h | 137 -- .../Eigen/src/SparseLU/SparseLU_pruneL.h | 135 -- .../Eigen/src/SparseLU/SparseLU_relax_snode.h | 83 - .../eigen3/Eigen/src/SparseQR/SparseQR.h | 714 ------- .../eigen3/Eigen/src/StlSupport/StdDeque.h | 126 -- .../eigen3/Eigen/src/StlSupport/StdList.h | 106 - .../eigen3/Eigen/src/StlSupport/StdVector.h | 126 -- .../eigen3/Eigen/src/StlSupport/details.h | 84 - .../Eigen/src/SuperLUSupport/SuperLUSupport.h | 1026 --------- .../Eigen/src/UmfPackSupport/UmfPackSupport.h | 474 ----- .../include/eigen3/Eigen/src/misc/Image.h | 84 - .../include/eigen3/Eigen/src/misc/Kernel.h | 81 - .../include/eigen3/Eigen/src/misc/Solve.h | 76 - .../eigen3/Eigen/src/misc/SparseSolve.h | 128 -- .../include/eigen3/Eigen/src/misc/blas.h | 658 ------ .../Eigen/src/plugins/ArrayCwiseBinaryOps.h | 253 --- .../Eigen/src/plugins/ArrayCwiseUnaryOps.h | 187 -- .../eigen3/Eigen/src/plugins/BlockMethods.h | 935 --------- .../Eigen/src/plugins/CommonCwiseBinaryOps.h | 46 - .../Eigen/src/plugins/CommonCwiseUnaryOps.h | 172 -- .../Eigen/src/plugins/MatrixCwiseBinaryOps.h | 143 -- .../Eigen/src/plugins/MatrixCwiseUnaryOps.h | 52 - .../eigen3/signature_of_eigen3_matrix_library | 1 - .../eigen3/unsupported/Eigen/AdolcForward | 156 -- .../eigen3/unsupported/Eigen/AlignedVector3 | 190 -- .../eigen3/unsupported/Eigen/ArpackSupport | 31 - .../include/eigen3/unsupported/Eigen/AutoDiff | 40 - .../include/eigen3/unsupported/Eigen/BVH | 95 - .../include/eigen3/unsupported/Eigen/FFT | 418 ---- .../eigen3/unsupported/Eigen/IterativeSolvers | 45 - .../eigen3/unsupported/Eigen/KroneckerProduct | 34 - .../unsupported/Eigen/LevenbergMarquardt | 45 - .../eigen3/unsupported/Eigen/MPRealSupport | 203 -- .../eigen3/unsupported/Eigen/MatrixFunctions | 447 ---- .../unsupported/Eigen/MoreVectorization | 24 - .../unsupported/Eigen/NonLinearOptimization | 134 -- .../eigen3/unsupported/Eigen/NumericalDiff | 56 - .../eigen3/unsupported/Eigen/OpenGLSupport | 322 --- .../eigen3/unsupported/Eigen/Polynomials | 138 -- .../include/eigen3/unsupported/Eigen/SVD | 39 - .../include/eigen3/unsupported/Eigen/Skyline | 39 - .../eigen3/unsupported/Eigen/SparseExtra | 56 - .../include/eigen3/unsupported/Eigen/Splines | 31 - .../Eigen/src/AutoDiff/AutoDiffJacobian.h | 83 - .../Eigen/src/AutoDiff/AutoDiffScalar.h | 642 ------ .../Eigen/src/AutoDiff/AutoDiffVector.h | 220 -- .../unsupported/Eigen/src/BVH/BVAlgorithms.h | 293 --- .../eigen3/unsupported/Eigen/src/BVH/KdBVH.h | 222 -- .../ArpackSelfAdjointEigenSolver.h | 805 ------- .../unsupported/Eigen/src/FFT/ei_fftw_impl.h | 261 --- .../Eigen/src/FFT/ei_kissfft_impl.h | 420 ---- .../IterativeSolvers/ConstrainedConjGrad.h | 189 -- .../Eigen/src/IterativeSolvers/DGMRES.h | 542 ----- .../Eigen/src/IterativeSolvers/GMRES.h | 371 ---- .../src/IterativeSolvers/IncompleteCholesky.h | 278 --- .../Eigen/src/IterativeSolvers/IncompleteLU.h | 113 - .../IterativeSolvers/IterationController.h | 154 -- .../Eigen/src/IterativeSolvers/MINRES.h | 311 --- .../Eigen/src/IterativeSolvers/Scaling.h | 185 -- .../KroneckerProduct/KroneckerTensorProduct.h | 244 --- .../LevenbergMarquardt/CopyrightMINPACK.txt | 52 - .../Eigen/src/LevenbergMarquardt/LMcovar.h | 85 - .../Eigen/src/LevenbergMarquardt/LMonestep.h | 202 -- .../Eigen/src/LevenbergMarquardt/LMpar.h | 160 -- .../Eigen/src/LevenbergMarquardt/LMqrsolv.h | 189 -- .../LevenbergMarquardt/LevenbergMarquardt.h | 377 ---- .../src/MatrixFunctions/MatrixExponential.h | 451 ---- .../src/MatrixFunctions/MatrixFunction.h | 591 ------ .../MatrixFunctions/MatrixFunctionAtomic.h | 131 -- .../src/MatrixFunctions/MatrixLogarithm.h | 486 ----- .../Eigen/src/MatrixFunctions/MatrixPower.h | 508 ----- .../src/MatrixFunctions/MatrixSquareRoot.h | 466 ----- .../Eigen/src/MatrixFunctions/StemFunction.h | 105 - .../src/MoreVectorization/MathFunctions.h | 95 - .../HybridNonLinearSolver.h | 601 ------ .../LevenbergMarquardt.h | 650 ------ .../Eigen/src/NonLinearOptimization/chkder.h | 66 - .../Eigen/src/NonLinearOptimization/covar.h | 70 - .../Eigen/src/NonLinearOptimization/dogleg.h | 107 - .../Eigen/src/NonLinearOptimization/fdjac1.h | 79 - .../Eigen/src/NonLinearOptimization/lmpar.h | 298 --- .../Eigen/src/NonLinearOptimization/qrsolv.h | 91 - .../Eigen/src/NonLinearOptimization/r1mpyq.h | 30 - .../Eigen/src/NonLinearOptimization/r1updt.h | 99 - .../Eigen/src/NonLinearOptimization/rwupdt.h | 49 - .../Eigen/src/NumericalDiff/NumericalDiff.h | 130 -- .../Eigen/src/Polynomials/Companion.h | 276 --- .../Eigen/src/Polynomials/PolynomialSolver.h | 389 ---- .../Eigen/src/Polynomials/PolynomialUtils.h | 143 -- .../eigen3/unsupported/Eigen/src/SVD/BDCSVD.h | 748 ------- .../unsupported/Eigen/src/SVD/JacobiSVD.h | 782 ------- .../unsupported/Eigen/src/SVD/SVDBase.h | 236 --- .../unsupported/Eigen/src/SVD/TODOBdcsvd.txt | 29 - .../Eigen/src/SVD/doneInBDCSVD.txt | 21 - .../Eigen/src/Skyline/SkylineInplaceLU.h | 352 ---- .../Eigen/src/Skyline/SkylineMatrix.h | 862 -------- .../Eigen/src/Skyline/SkylineMatrixBase.h | 212 -- .../Eigen/src/Skyline/SkylineProduct.h | 295 --- .../Eigen/src/Skyline/SkylineStorage.h | 259 --- .../Eigen/src/Skyline/SkylineUtil.h | 89 - .../SparseExtra/BlockOfDynamicSparseMatrix.h | 122 -- .../src/SparseExtra/DynamicSparseMatrix.h | 357 ---- .../Eigen/src/SparseExtra/MarketIO.h | 273 --- .../src/SparseExtra/MatrixMarketIterator.h | 232 --- .../Eigen/src/SparseExtra/RandomSetter.h | 327 --- .../unsupported/Eigen/src/Splines/Spline.h | 474 ----- .../Eigen/src/Splines/SplineFitting.h | 156 -- .../unsupported/Eigen/src/Splines/SplineFwd.h | 90 - .../include/eigen3/unsupported/README.txt | 50 - 373 files changed, 101347 deletions(-) delete mode 100644 modules/algebra/include/eigen3/Eigen/Array delete mode 100644 modules/algebra/include/eigen3/Eigen/Cholesky delete mode 100644 modules/algebra/include/eigen3/Eigen/CholmodSupport delete mode 100644 modules/algebra/include/eigen3/Eigen/Core delete mode 100644 modules/algebra/include/eigen3/Eigen/Dense delete mode 100644 modules/algebra/include/eigen3/Eigen/Eigen delete mode 100644 modules/algebra/include/eigen3/Eigen/Eigen2Support delete mode 100644 modules/algebra/include/eigen3/Eigen/Eigenvalues delete mode 100644 modules/algebra/include/eigen3/Eigen/Geometry delete mode 100644 modules/algebra/include/eigen3/Eigen/Householder delete mode 100644 modules/algebra/include/eigen3/Eigen/IterativeLinearSolvers delete mode 100644 modules/algebra/include/eigen3/Eigen/Jacobi delete mode 100644 modules/algebra/include/eigen3/Eigen/LU delete mode 100644 modules/algebra/include/eigen3/Eigen/LeastSquares delete mode 100644 modules/algebra/include/eigen3/Eigen/MetisSupport delete mode 100644 modules/algebra/include/eigen3/Eigen/OrderingMethods delete mode 100644 modules/algebra/include/eigen3/Eigen/PaStiXSupport delete mode 100644 modules/algebra/include/eigen3/Eigen/PardisoSupport delete mode 100644 modules/algebra/include/eigen3/Eigen/QR delete mode 100644 modules/algebra/include/eigen3/Eigen/QtAlignedMalloc delete mode 100644 modules/algebra/include/eigen3/Eigen/SPQRSupport delete mode 100644 modules/algebra/include/eigen3/Eigen/SVD delete mode 100644 modules/algebra/include/eigen3/Eigen/Sparse delete mode 100644 modules/algebra/include/eigen3/Eigen/SparseCholesky delete mode 100644 modules/algebra/include/eigen3/Eigen/SparseCore delete mode 100644 modules/algebra/include/eigen3/Eigen/SparseLU delete mode 100644 modules/algebra/include/eigen3/Eigen/SparseQR delete mode 100644 modules/algebra/include/eigen3/Eigen/StdDeque delete mode 100644 modules/algebra/include/eigen3/Eigen/StdList delete mode 100644 modules/algebra/include/eigen3/Eigen/StdVector delete mode 100644 modules/algebra/include/eigen3/Eigen/SuperLUSupport delete mode 100644 modules/algebra/include/eigen3/Eigen/UmfPackSupport delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Cholesky/LDLT.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Array.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/ArrayBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/ArrayWrapper.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Assign.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Assign_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/BandMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Block.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/BooleanRedux.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/CommaInitializer.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/CoreIterators.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/CwiseNullaryOp.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryOp.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryView.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/DenseBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/DenseStorage.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Diagonal.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/DiagonalMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/DiagonalProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Dot.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/EigenBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Flagged.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/ForceAlignedAccess.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Functors.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Fuzzy.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/GeneralProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/GenericPacketMath.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/GlobalFunctions.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/IO.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Map.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/MapBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/MathFunctions.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Matrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/MatrixBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/NestByValue.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/NoAlias.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/NumTraits.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/PermutationMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/PlainObjectBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/ProductBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Random.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Redux.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Ref.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Replicate.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/ReturnByValue.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Reverse.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Select.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/SelfAdjointView.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/SolveTriangular.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/StableNorm.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Stride.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Swap.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Transpose.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Transpositions.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/TriangularMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/VectorBlock.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/VectorwiseOp.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/Visitor.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/Default/Settings.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/NEON/Complex.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/GeneralMatrixVector_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/Parallelizer.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/SelfadjointProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/TriangularMatrixVector_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/products/TriangularSolverVector.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/BlasUtil.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/Constants.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/MKL_support.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/Macros.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/Memory.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/Meta.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/NonMPL2.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/StaticAssert.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Core/util/XprHelper.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Block.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Cwise.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/CwiseOperators.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/All.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/LU.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Lazy.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/LeastSquares.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Macros.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/MathFunctions.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Memory.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Meta.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/Minor.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/QR.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/SVD.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/TriangularSolver.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigen2Support/VectorBlock.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/ComplexSchur_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/EigenSolver.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/RealQZ.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/RealSchur.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/RealSchur_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/AlignedBox.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/AngleAxis.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/EulerAngles.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Homogeneous.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Hyperplane.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/OrthoMethods.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/ParametrizedLine.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Quaternion.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Rotation2D.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/RotationBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Scaling.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Transform.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Translation.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/Umeyama.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Householder/BlockHouseholder.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Householder/Householder.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Householder/HouseholderSequence.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/Jacobi/Jacobi.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/LU/Determinant.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/LU/FullPivLU.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/LU/Inverse.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/LU/PartialPivLU.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/LU/PartialPivLU_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/LU/arch/Inverse_SSE.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/MetisSupport/MetisSupport.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/OrderingMethods/Amd.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/OrderingMethods/Ordering.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/QR/ColPivHouseholderQR.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/QR/ColPivHouseholderQR_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/QR/FullPivHouseholderQR.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/QR/HouseholderQR.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/QR/HouseholderQR_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SVD/JacobiSVD.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SVD/JacobiSVD_MKL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SVD/UpperBidiagonalization.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/AmbiVector.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/CompressedStorage.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseBlock.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseColEtree.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseDot.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseFuzzy.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparsePermutation.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseProduct.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseRedux.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseTranspose.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseTriangularView.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseUtil.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseVector.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/SparseView.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseCore/TriangularSolver.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLUImpl.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SparseQR/SparseQR.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/StlSupport/StdDeque.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/StlSupport/StdList.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/StlSupport/StdVector.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/StlSupport/details.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/misc/Image.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/misc/Kernel.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/misc/Solve.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/misc/SparseSolve.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/misc/blas.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/plugins/BlockMethods.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h delete mode 100644 modules/algebra/include/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h delete mode 100644 modules/algebra/include/eigen3/signature_of_eigen3_matrix_library delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/AdolcForward delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/AlignedVector3 delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/ArpackSupport delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/AutoDiff delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/BVH delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/FFT delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/IterativeSolvers delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/KroneckerProduct delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/LevenbergMarquardt delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/MPRealSupport delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/MatrixFunctions delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/MoreVectorization delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/NonLinearOptimization delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/NumericalDiff delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/OpenGLSupport delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/Polynomials delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/SVD delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/Skyline delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/SparseExtra delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/Splines delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/BVH/BVAlgorithms.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/BVH/KdBVH.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/FFT/ei_fftw_impl.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/FFT/ei_kissfft_impl.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/DGMRES.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/GMRES.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/IterationController.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/MINRES.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/IterativeSolvers/Scaling.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/CopyrightMINPACK.txt delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MatrixFunctions/StemFunction.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/MoreVectorization/MathFunctions.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/chkder.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/covar.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/dogleg.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/lmpar.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1updt.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Polynomials/Companion.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Polynomials/PolynomialSolver.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Polynomials/PolynomialUtils.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SVD/BDCSVD.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SVD/JacobiSVD.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SVD/SVDBase.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SVD/TODOBdcsvd.txt delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SVD/doneInBDCSVD.txt delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrix.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Skyline/SkylineProduct.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Skyline/SkylineStorage.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Skyline/SkylineUtil.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SparseExtra/MarketIO.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/SparseExtra/RandomSetter.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Splines/Spline.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Splines/SplineFitting.h delete mode 100644 modules/algebra/include/eigen3/unsupported/Eigen/src/Splines/SplineFwd.h delete mode 100644 modules/algebra/include/eigen3/unsupported/README.txt diff --git a/modules/algebra/include/eigen3/Eigen/Array b/modules/algebra/include/eigen3/Eigen/Array deleted file mode 100644 index 3c6ef277fc..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Array +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef IMP_EIGEN_ARRAY_MODULE_H -#define IMP_EIGEN_ARRAY_MODULE_H - -// include Core first to handle Eigen2 support macros -#include "Core" - -#ifndef IMP_EIGEN2_SUPPORT - #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. -#endif - -#endif // IMP_EIGEN_ARRAY_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/Cholesky b/modules/algebra/include/eigen3/Eigen/Cholesky deleted file mode 100644 index 858bf5128d..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Cholesky +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef IMP_EIGEN_CHOLESKY_MODULE_H -#define IMP_EIGEN_CHOLESKY_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** \defgroup Cholesky_Module Cholesky module - * - * - * - * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. - * Those decompositions are accessible via the following MatrixBase methods: - * - MatrixBase::llt(), - * - MatrixBase::ldlt() - * - * \code - * #include - * \endcode - */ - -#include "src/misc/Solve.h" -#include "src/Cholesky/LLT.h" -#include "src/Cholesky/LDLT.h" -#ifdef IMP_EIGEN_USE_LAPACKE -#include "src/Cholesky/LLT_MKL.h" -#endif - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_CHOLESKY_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/modules/algebra/include/eigen3/Eigen/CholmodSupport b/modules/algebra/include/eigen3/Eigen/CholmodSupport deleted file mode 100644 index cba956c3be..0000000000 --- a/modules/algebra/include/eigen3/Eigen/CholmodSupport +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef IMP_EIGEN_CHOLMODSUPPORT_MODULE_H -#define IMP_EIGEN_CHOLMODSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -extern "C" { - #include -} - -/** \ingroup Support_modules - * \defgroup CholmodSupport_Module CholmodSupport module - * - * This module provides an interface to the Cholmod library which is part of the suitesparse package. - * It provides the two following main factorization classes: - * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. - * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). - * - * For the sake of completeness, this module also propose the two following classes: - * - class CholmodSimplicialLLT - * - class CholmodSimplicialLDLT - * Note that these classes does not bring any particular advantage compared to the built-in - * SimplicialLLT and SimplicialLDLT factorization classes. - * - * \code - * #include - * \endcode - * - * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. - * The dependencies depend on how cholmod has been compiled. - * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. - * - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" - -#include "src/CholmodSupport/CholmodSupport.h" - - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_CHOLMODSUPPORT_MODULE_H - diff --git a/modules/algebra/include/eigen3/Eigen/Core b/modules/algebra/include/eigen3/Eigen/Core deleted file mode 100644 index 2fe64f6c79..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Core +++ /dev/null @@ -1,376 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2007-2011 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_CORE_H -#define IMP_EIGEN_CORE_H - -// first thing Eigen does: stop the compiler from committing suicide -#include "src/Core/util/DisableStupidWarnings.h" - -// then include this file where all our macros are defined. It's really important to do it first because -// it's where we do all the alignment settings (platform detection and honoring the user's will if he -// defined e.g. IMP_EIGEN_DONT_ALIGN) so it needs to be done before we do anything with vectorization. -#include "src/Core/util/Macros.h" - -// Disable the ipa-cp-clone optimization flag with MinGW 6.x or newer (enabled by default with -O3) -// See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 for details. -#if defined(__MINGW32__) && IMP_EIGEN_GNUC_AT_LEAST(4,6) - #pragma GCC optimize ("-fno-ipa-cp-clone") -#endif - -#include - -// this include file manages BLAS and MKL related macros -// and inclusion of their respective header files -#include "src/Core/util/MKL_support.h" - -// if alignment is disabled, then disable vectorization. Note: IMP_EIGEN_ALIGN is the proper check, it takes into -// account both the user's will (IMP_EIGEN_DONT_ALIGN) and our own platform checks -#if !IMP_EIGEN_ALIGN - #ifndef IMP_EIGEN_DONT_VECTORIZE - #define IMP_EIGEN_DONT_VECTORIZE - #endif -#endif - -#ifdef _MSC_VER - #include // for _aligned_malloc -- need it regardless of whether vectorization is enabled - #if (_MSC_VER >= 1500) // 2008 or later - // Remember that usage of defined() in a #define is undefined by the standard. - // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP. - #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(_M_X64) - #define IMP_EIGEN_SSE2_ON_MSVC_2008_OR_LATER - #endif - #endif -#else - // Remember that usage of defined() in a #define is undefined by the standard - #if (defined __SSE2__) && ( (!defined __GNUC__) || (defined __INTEL_COMPILER) || IMP_EIGEN_GNUC_AT_LEAST(4,2) ) - #define IMP_EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC - #endif -#endif - -#ifndef IMP_EIGEN_DONT_VECTORIZE - - #if defined (IMP_EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC) || defined(IMP_EIGEN_SSE2_ON_MSVC_2008_OR_LATER) - - // Defines symbols for compile-time detection of which instructions are - // used. - // IMP_EIGEN_VECTORIZE_YY is defined if and only if the instruction set YY is used - #define IMP_EIGEN_VECTORIZE - #define IMP_EIGEN_VECTORIZE_SSE - #define IMP_EIGEN_VECTORIZE_SSE2 - - // Detect sse3/ssse3/sse4: - // gcc and icc defines __SSE3__, ... - // there is no way to know about this on msvc. You can define IMP_EIGEN_VECTORIZE_SSE* if you - // want to force the use of those instructions with msvc. - #ifdef __SSE3__ - #define IMP_EIGEN_VECTORIZE_SSE3 - #endif - #ifdef __SSSE3__ - #define IMP_EIGEN_VECTORIZE_SSSE3 - #endif - #ifdef __SSE4_1__ - #define IMP_EIGEN_VECTORIZE_SSE4_1 - #endif - #ifdef __SSE4_2__ - #define IMP_EIGEN_VECTORIZE_SSE4_2 - #endif - - // include files - - // This extern "C" works around a MINGW-w64 compilation issue - // https://sourceforge.net/tracker/index.php?func=detail&aid=3018394&group_id=202880&atid=983354 - // In essence, intrin.h is included by windows.h and also declares intrinsics (just as emmintrin.h etc. below do). - // However, intrin.h uses an extern "C" declaration, and g++ thus complains of duplicate declarations - // with conflicting linkage. The linkage for intrinsics doesn't matter, but at that stage the compiler doesn't know; - // so, to avoid compile errors when windows.h is included after Eigen/Core, ensure intrinsics are extern "C" here too. - // notice that since these are C headers, the extern "C" is theoretically needed anyways. - extern "C" { - // In theory we should only include immintrin.h and not the other *mmintrin.h header files directly. - // Doing so triggers some issues with ICC. However old gcc versions seems to not have this file, thus: - #if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1110 - #include - #else - #include - #include - #ifdef IMP_EIGEN_VECTORIZE_SSE3 - #include - #endif - #ifdef IMP_EIGEN_VECTORIZE_SSSE3 - #include - #endif - #ifdef IMP_EIGEN_VECTORIZE_SSE4_1 - #include - #endif - #ifdef IMP_EIGEN_VECTORIZE_SSE4_2 - #include - #endif - #endif - } // end extern "C" - #elif defined __ALTIVEC__ - #define IMP_EIGEN_VECTORIZE - #define IMP_EIGEN_VECTORIZE_ALTIVEC - #include - // We need to #undef all these ugly tokens defined in - // => use __vector instead of vector - #undef bool - #undef vector - #undef pixel - #elif defined __ARM_NEON - #define IMP_EIGEN_VECTORIZE - #define IMP_EIGEN_VECTORIZE_NEON - #include - #endif -#endif - -#if (defined _OPENMP) && (!defined IMP_EIGEN_DONT_PARALLELIZE) - #define IMP_EIGEN_HAS_OPENMP -#endif - -#ifdef IMP_EIGEN_HAS_OPENMP -#include -#endif - -// MSVC for windows mobile does not have the errno.h file -#if !(defined(_MSC_VER) && defined(_WIN32_WCE)) && !defined(__ARMCC_VERSION) -#define IMP_EIGEN_HAS_ERRNO -#endif - -#ifdef IMP_EIGEN_HAS_ERRNO -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // for CHAR_BIT -// for min/max: -#include - -// for outputting debug info -#ifdef IMP_EIGEN_DEBUG_ASSIGN -#include -#endif - -// required for __cpuid, needs to be included after cmath -#if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64)) && (!defined(_WIN32_WCE)) - #include -#endif - -#if defined(_CPPUNWIND) || defined(__EXCEPTIONS) - #define IMP_EIGEN_EXCEPTIONS -#endif - -#ifdef IMP_EIGEN_EXCEPTIONS - #include -#endif - -/** \brief Namespace containing all symbols from the %Eigen library. */ -namespace IMP_Eigen { - -inline static const char *SimdInstructionSetsInUse(void) { -#if defined(IMP_EIGEN_VECTORIZE_SSE4_2) - return "SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2"; -#elif defined(IMP_EIGEN_VECTORIZE_SSE4_1) - return "SSE, SSE2, SSE3, SSSE3, SSE4.1"; -#elif defined(IMP_EIGEN_VECTORIZE_SSSE3) - return "SSE, SSE2, SSE3, SSSE3"; -#elif defined(IMP_EIGEN_VECTORIZE_SSE3) - return "SSE, SSE2, SSE3"; -#elif defined(IMP_EIGEN_VECTORIZE_SSE2) - return "SSE, SSE2"; -#elif defined(IMP_EIGEN_VECTORIZE_ALTIVEC) - return "AltiVec"; -#elif defined(IMP_EIGEN_VECTORIZE_NEON) - return "ARM NEON"; -#else - return "None"; -#endif -} - -} // end namespace IMP_Eigen - -#define STAGE10_FULL_EIGEN2_API 10 -#define STAGE20_RESOLVE_API_CONFLICTS 20 -#define STAGE30_FULL_EIGEN3_API 30 -#define STAGE40_FULL_EIGEN3_STRICTNESS 40 -#define STAGE99_NO_EIGEN2_SUPPORT 99 - -#if defined IMP_EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS - #define IMP_EIGEN2_SUPPORT - #define IMP_EIGEN2_SUPPORT_STAGE STAGE40_FULL_EIGEN3_STRICTNESS -#elif defined IMP_EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API - #define IMP_EIGEN2_SUPPORT - #define IMP_EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API -#elif defined IMP_EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS - #define IMP_EIGEN2_SUPPORT - #define IMP_EIGEN2_SUPPORT_STAGE STAGE20_RESOLVE_API_CONFLICTS -#elif defined IMP_EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API - #define IMP_EIGEN2_SUPPORT - #define IMP_EIGEN2_SUPPORT_STAGE STAGE10_FULL_EIGEN2_API -#elif defined IMP_EIGEN2_SUPPORT - // default to stage 3, that's what it's always meant - #define IMP_EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API - #define IMP_EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API -#else - #define IMP_EIGEN2_SUPPORT_STAGE STAGE99_NO_EIGEN2_SUPPORT -#endif - -#ifdef IMP_EIGEN2_SUPPORT -#undef minor -#endif - -// we use size_t frequently and we'll never remember to prepend it with std:: everytime just to -// ensure QNX/QCC support -using std::size_t; -// gcc 4.6.0 wants std:: for ptrdiff_t -using std::ptrdiff_t; - -/** \defgroup Core_Module Core module - * This is the main module of Eigen providing dense matrix and vector support - * (both fixed and dynamic size) with all the features corresponding to a BLAS library - * and much more... - * - * \code - * #include - * \endcode - */ - -#include "src/Core/util/Constants.h" -#include "src/Core/util/ForwardDeclarations.h" -#include "src/Core/util/Meta.h" -#include "src/Core/util/StaticAssert.h" -#include "src/Core/util/XprHelper.h" -#include "src/Core/util/Memory.h" - -#include "src/Core/NumTraits.h" -#include "src/Core/MathFunctions.h" -#include "src/Core/GenericPacketMath.h" - -#if defined IMP_EIGEN_VECTORIZE_SSE - #include "src/Core/arch/SSE/PacketMath.h" - #include "src/Core/arch/SSE/MathFunctions.h" - #include "src/Core/arch/SSE/Complex.h" -#elif defined IMP_EIGEN_VECTORIZE_ALTIVEC - #include "src/Core/arch/AltiVec/PacketMath.h" - #include "src/Core/arch/AltiVec/Complex.h" -#elif defined IMP_EIGEN_VECTORIZE_NEON - #include "src/Core/arch/NEON/PacketMath.h" - #include "src/Core/arch/NEON/Complex.h" -#endif - -#include "src/Core/arch/Default/Settings.h" - -#include "src/Core/Functors.h" -#include "src/Core/DenseCoeffsBase.h" -#include "src/Core/DenseBase.h" -#include "src/Core/MatrixBase.h" -#include "src/Core/EigenBase.h" - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874 - // at least confirmed with Doxygen 1.5.5 and 1.5.6 - #include "src/Core/Assign.h" -#endif - -#include "src/Core/util/BlasUtil.h" -#include "src/Core/DenseStorage.h" -#include "src/Core/NestByValue.h" -#include "src/Core/ForceAlignedAccess.h" -#include "src/Core/ReturnByValue.h" -#include "src/Core/NoAlias.h" -#include "src/Core/PlainObjectBase.h" -#include "src/Core/Matrix.h" -#include "src/Core/Array.h" -#include "src/Core/CwiseBinaryOp.h" -#include "src/Core/CwiseUnaryOp.h" -#include "src/Core/CwiseNullaryOp.h" -#include "src/Core/CwiseUnaryView.h" -#include "src/Core/SelfCwiseBinaryOp.h" -#include "src/Core/Dot.h" -#include "src/Core/StableNorm.h" -#include "src/Core/MapBase.h" -#include "src/Core/Stride.h" -#include "src/Core/Map.h" -#include "src/Core/Block.h" -#include "src/Core/VectorBlock.h" -#include "src/Core/Ref.h" -#include "src/Core/Transpose.h" -#include "src/Core/DiagonalMatrix.h" -#include "src/Core/Diagonal.h" -#include "src/Core/DiagonalProduct.h" -#include "src/Core/PermutationMatrix.h" -#include "src/Core/Transpositions.h" -#include "src/Core/Redux.h" -#include "src/Core/Visitor.h" -#include "src/Core/Fuzzy.h" -#include "src/Core/IO.h" -#include "src/Core/Swap.h" -#include "src/Core/CommaInitializer.h" -#include "src/Core/Flagged.h" -#include "src/Core/ProductBase.h" -#include "src/Core/GeneralProduct.h" -#include "src/Core/TriangularMatrix.h" -#include "src/Core/SelfAdjointView.h" -#include "src/Core/products/GeneralBlockPanelKernel.h" -#include "src/Core/products/Parallelizer.h" -#include "src/Core/products/CoeffBasedProduct.h" -#include "src/Core/products/GeneralMatrixVector.h" -#include "src/Core/products/GeneralMatrixMatrix.h" -#include "src/Core/SolveTriangular.h" -#include "src/Core/products/GeneralMatrixMatrixTriangular.h" -#include "src/Core/products/SelfadjointMatrixVector.h" -#include "src/Core/products/SelfadjointMatrixMatrix.h" -#include "src/Core/products/SelfadjointProduct.h" -#include "src/Core/products/SelfadjointRank2Update.h" -#include "src/Core/products/TriangularMatrixVector.h" -#include "src/Core/products/TriangularMatrixMatrix.h" -#include "src/Core/products/TriangularSolverMatrix.h" -#include "src/Core/products/TriangularSolverVector.h" -#include "src/Core/BandMatrix.h" -#include "src/Core/CoreIterators.h" - -#include "src/Core/BooleanRedux.h" -#include "src/Core/Select.h" -#include "src/Core/VectorwiseOp.h" -#include "src/Core/Random.h" -#include "src/Core/Replicate.h" -#include "src/Core/Reverse.h" -#include "src/Core/ArrayBase.h" -#include "src/Core/ArrayWrapper.h" - -#ifdef IMP_EIGEN_USE_BLAS -#include "src/Core/products/GeneralMatrixMatrix_MKL.h" -#include "src/Core/products/GeneralMatrixVector_MKL.h" -#include "src/Core/products/GeneralMatrixMatrixTriangular_MKL.h" -#include "src/Core/products/SelfadjointMatrixMatrix_MKL.h" -#include "src/Core/products/SelfadjointMatrixVector_MKL.h" -#include "src/Core/products/TriangularMatrixMatrix_MKL.h" -#include "src/Core/products/TriangularMatrixVector_MKL.h" -#include "src/Core/products/TriangularSolverMatrix_MKL.h" -#endif // IMP_EIGEN_USE_BLAS - -#ifdef IMP_EIGEN_USE_MKL_VML -#include "src/Core/Assign_MKL.h" -#endif - -#include "src/Core/GlobalFunctions.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#ifdef IMP_EIGEN2_SUPPORT -#include "Eigen2Support" -#endif - -#endif // IMP_EIGEN_CORE_H diff --git a/modules/algebra/include/eigen3/Eigen/Dense b/modules/algebra/include/eigen3/Eigen/Dense deleted file mode 100644 index 5768910bd8..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Dense +++ /dev/null @@ -1,7 +0,0 @@ -#include "Core" -#include "LU" -#include "Cholesky" -#include "QR" -#include "SVD" -#include "Geometry" -#include "Eigenvalues" diff --git a/modules/algebra/include/eigen3/Eigen/Eigen b/modules/algebra/include/eigen3/Eigen/Eigen deleted file mode 100644 index 19b40ea4e7..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Eigen +++ /dev/null @@ -1,2 +0,0 @@ -#include "Dense" -//#include "Sparse" diff --git a/modules/algebra/include/eigen3/Eigen/Eigen2Support b/modules/algebra/include/eigen3/Eigen/Eigen2Support deleted file mode 100644 index dc606f3fac..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Eigen2Support +++ /dev/null @@ -1,95 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN2SUPPORT_H -#define IMP_EIGEN2SUPPORT_H - -#if (!defined(IMP_EIGEN2_SUPPORT)) || (!defined(IMP_EIGEN_CORE_H)) -#error Eigen2 support must be enabled by defining IMP_EIGEN2_SUPPORT before including any Eigen header -#endif - -#ifndef IMP_EIGEN_NO_EIGEN2_DEPRECATED_WARNING - -#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) -#warning "Eigen2 support is deprecated in Eigen 3.2.x and it will be removed in Eigen 3.3. (Define IMP_EIGEN_NO_EIGEN2_DEPRECATED_WARNING to disable this warning)" -#else -#pragma message ("Eigen2 support is deprecated in Eigen 3.2.x and it will be removed in Eigen 3.3. (Define IMP_EIGEN_NO_EIGEN2_DEPRECATED_WARNING to disable this warning)") -#endif - -#endif // IMP_EIGEN_NO_EIGEN2_DEPRECATED_WARNING - -#include "src/Core/util/DisableStupidWarnings.h" - -/** \ingroup Support_modules - * \defgroup Eigen2Support_Module Eigen2 support module - * - * \warning Eigen2 support is deprecated in Eigen 3.2.x and it will be removed in Eigen 3.3. - * - * This module provides a couple of deprecated functions improving the compatibility with Eigen2. - * - * To use it, define IMP_EIGEN2_SUPPORT before including any Eigen header - * \code - * #define IMP_EIGEN2_SUPPORT - * \endcode - * - */ - -#include "src/Eigen2Support/Macros.h" -#include "src/Eigen2Support/Memory.h" -#include "src/Eigen2Support/Meta.h" -#include "src/Eigen2Support/Lazy.h" -#include "src/Eigen2Support/Cwise.h" -#include "src/Eigen2Support/CwiseOperators.h" -#include "src/Eigen2Support/TriangularSolver.h" -#include "src/Eigen2Support/Block.h" -#include "src/Eigen2Support/VectorBlock.h" -#include "src/Eigen2Support/Minor.h" -#include "src/Eigen2Support/MathFunctions.h" - - -#include "src/Core/util/ReenableStupidWarnings.h" - -// Eigen2 used to include iostream -#include - -#define IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \ -using IMP_Eigen::Matrix##SizeSuffix##TypeSuffix; \ -using IMP_Eigen::Vector##SizeSuffix##TypeSuffix; \ -using IMP_Eigen::RowVector##SizeSuffix##TypeSuffix; - -#define IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \ - -#define IMP_EIGEN_USING_MATRIX_TYPEDEFS \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd) - -#define USING_PART_OF_NAMESPACE_EIGEN \ -IMP_EIGEN_USING_MATRIX_TYPEDEFS \ -using IMP_Eigen::Matrix; \ -using IMP_Eigen::MatrixBase; \ -using IMP_Eigen::ei_random; \ -using IMP_Eigen::ei_real; \ -using IMP_Eigen::ei_imag; \ -using IMP_Eigen::ei_conj; \ -using IMP_Eigen::ei_abs; \ -using IMP_Eigen::ei_abs2; \ -using IMP_Eigen::ei_sqrt; \ -using IMP_Eigen::ei_exp; \ -using IMP_Eigen::ei_log; \ -using IMP_Eigen::ei_sin; \ -using IMP_Eigen::ei_cos; - -#endif // IMP_EIGEN2SUPPORT_H diff --git a/modules/algebra/include/eigen3/Eigen/Eigenvalues b/modules/algebra/include/eigen3/Eigen/Eigenvalues deleted file mode 100644 index 3ff0d27dba..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Eigenvalues +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef IMP_EIGEN_EIGENVALUES_MODULE_H -#define IMP_EIGEN_EIGENVALUES_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include "Cholesky" -#include "Jacobi" -#include "Householder" -#include "LU" -#include "Geometry" - -/** \defgroup Eigenvalues_Module Eigenvalues module - * - * - * - * This module mainly provides various eigenvalue solvers. - * This module also provides some MatrixBase methods, including: - * - MatrixBase::eigenvalues(), - * - MatrixBase::operatorNorm() - * - * \code - * #include - * \endcode - */ - -#include "src/Eigenvalues/Tridiagonalization.h" -#include "src/Eigenvalues/RealSchur.h" -#include "src/Eigenvalues/EigenSolver.h" -#include "src/Eigenvalues/SelfAdjointEigenSolver.h" -#include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" -#include "src/Eigenvalues/HessenbergDecomposition.h" -#include "src/Eigenvalues/ComplexSchur.h" -#include "src/Eigenvalues/ComplexEigenSolver.h" -#include "src/Eigenvalues/RealQZ.h" -#include "src/Eigenvalues/GeneralizedEigenSolver.h" -#include "src/Eigenvalues/MatrixBaseEigenvalues.h" -#ifdef IMP_EIGEN_USE_LAPACKE -#include "src/Eigenvalues/RealSchur_MKL.h" -#include "src/Eigenvalues/ComplexSchur_MKL.h" -#include "src/Eigenvalues/SelfAdjointEigenSolver_MKL.h" -#endif - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_EIGENVALUES_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/modules/algebra/include/eigen3/Eigen/Geometry b/modules/algebra/include/eigen3/Eigen/Geometry deleted file mode 100644 index 38e3479811..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Geometry +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef IMP_EIGEN_GEOMETRY_MODULE_H -#define IMP_EIGEN_GEOMETRY_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include "SVD" -#include "LU" -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -/** \defgroup Geometry_Module Geometry module - * - * - * - * This module provides support for: - * - fixed-size homogeneous transformations - * - translation, scaling, 2D and 3D rotations - * - quaternions - * - \ref MatrixBase::cross() "cross product" - * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" - * - some linear components: parametrized-lines and hyperplanes - * - * \code - * #include - * \endcode - */ - -#include "src/Geometry/OrthoMethods.h" -#include "src/Geometry/EulerAngles.h" - -#if IMP_EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS - #include "src/Geometry/Homogeneous.h" - #include "src/Geometry/RotationBase.h" - #include "src/Geometry/Rotation2D.h" - #include "src/Geometry/Quaternion.h" - #include "src/Geometry/AngleAxis.h" - #include "src/Geometry/Transform.h" - #include "src/Geometry/Translation.h" - #include "src/Geometry/Scaling.h" - #include "src/Geometry/Hyperplane.h" - #include "src/Geometry/ParametrizedLine.h" - #include "src/Geometry/AlignedBox.h" - #include "src/Geometry/Umeyama.h" - - #if defined IMP_EIGEN_VECTORIZE_SSE - #include "src/Geometry/arch/Geometry_SSE.h" - #endif -#endif - -#ifdef IMP_EIGEN2_SUPPORT -#include "src/Eigen2Support/Geometry/All.h" -#endif - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_GEOMETRY_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ - diff --git a/modules/algebra/include/eigen3/Eigen/Householder b/modules/algebra/include/eigen3/Eigen/Householder deleted file mode 100644 index 775a037e6b..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Householder +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef IMP_EIGEN_HOUSEHOLDER_MODULE_H -#define IMP_EIGEN_HOUSEHOLDER_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** \defgroup Householder_Module Householder module - * This module provides Householder transformations. - * - * \code - * #include - * \endcode - */ - -#include "src/Householder/Householder.h" -#include "src/Householder/HouseholderSequence.h" -#include "src/Householder/BlockHouseholder.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_HOUSEHOLDER_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/modules/algebra/include/eigen3/Eigen/IterativeLinearSolvers b/modules/algebra/include/eigen3/Eigen/IterativeLinearSolvers deleted file mode 100644 index 6ea17f3862..0000000000 --- a/modules/algebra/include/eigen3/Eigen/IterativeLinearSolvers +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef IMP_EIGEN_ITERATIVELINEARSOLVERS_MODULE_H -#define IMP_EIGEN_ITERATIVELINEARSOLVERS_MODULE_H - -#include "SparseCore" -#include "OrderingMethods" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** - * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module - * - * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. - * Those solvers are accessible via the following classes: - * - ConjugateGradient for selfadjoint (hermitian) matrices, - * - BiCGSTAB for general square matrices. - * - * These iterative solvers are associated with some preconditioners: - * - IdentityPreconditioner - not really useful - * - DiagonalPreconditioner - also called JAcobi preconditioner, work very well on diagonal dominant matrices. - * - IncompleteILUT - incomplete LU factorization with dual thresholding - * - * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. - * - * \code - * #include - * \endcode - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" - -#include "src/IterativeLinearSolvers/IterativeSolverBase.h" -#include "src/IterativeLinearSolvers/BasicPreconditioners.h" -#include "src/IterativeLinearSolvers/ConjugateGradient.h" -#include "src/IterativeLinearSolvers/BiCGSTAB.h" -#include "src/IterativeLinearSolvers/IncompleteLUT.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_ITERATIVELINEARSOLVERS_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/Jacobi b/modules/algebra/include/eigen3/Eigen/Jacobi deleted file mode 100644 index 2ec621160a..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Jacobi +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef IMP_EIGEN_JACOBI_MODULE_H -#define IMP_EIGEN_JACOBI_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** \defgroup Jacobi_Module Jacobi module - * This module provides Jacobi and Givens rotations. - * - * \code - * #include - * \endcode - * - * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: - * - MatrixBase::applyOnTheLeft() - * - MatrixBase::applyOnTheRight(). - */ - -#include "src/Jacobi/Jacobi.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_JACOBI_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ - diff --git a/modules/algebra/include/eigen3/Eigen/LU b/modules/algebra/include/eigen3/Eigen/LU deleted file mode 100644 index d2f3301998..0000000000 --- a/modules/algebra/include/eigen3/Eigen/LU +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef IMP_EIGEN_LU_MODULE_H -#define IMP_EIGEN_LU_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** \defgroup LU_Module LU module - * This module includes %LU decomposition and related notions such as matrix inversion and determinant. - * This module defines the following MatrixBase methods: - * - MatrixBase::inverse() - * - MatrixBase::determinant() - * - * \code - * #include - * \endcode - */ - -#include "src/misc/Solve.h" -#include "src/misc/Kernel.h" -#include "src/misc/Image.h" -#include "src/LU/FullPivLU.h" -#include "src/LU/PartialPivLU.h" -#ifdef IMP_EIGEN_USE_LAPACKE -#include "src/LU/PartialPivLU_MKL.h" -#endif -#include "src/LU/Determinant.h" -#include "src/LU/Inverse.h" - -#if defined IMP_EIGEN_VECTORIZE_SSE - #include "src/LU/arch/Inverse_SSE.h" -#endif - -#ifdef IMP_EIGEN2_SUPPORT - #include "src/Eigen2Support/LU.h" -#endif - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_LU_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/modules/algebra/include/eigen3/Eigen/LeastSquares b/modules/algebra/include/eigen3/Eigen/LeastSquares deleted file mode 100644 index 71ab5b4b44..0000000000 --- a/modules/algebra/include/eigen3/Eigen/LeastSquares +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef IMP_EIGEN_REGRESSION_MODULE_H -#define IMP_EIGEN_REGRESSION_MODULE_H - -#ifndef IMP_EIGEN2_SUPPORT -#error LeastSquares is only available in Eigen2 support mode (define IMP_EIGEN2_SUPPORT) -#endif - -// exclude from normal eigen3-only documentation -#ifdef IMP_EIGEN2_SUPPORT - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include "Eigenvalues" -#include "Geometry" - -/** \defgroup LeastSquares_Module LeastSquares module - * This module provides linear regression and related features. - * - * \code - * #include - * \endcode - */ - -#include "src/Eigen2Support/LeastSquares.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN2_SUPPORT - -#endif // IMP_EIGEN_REGRESSION_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/MetisSupport b/modules/algebra/include/eigen3/Eigen/MetisSupport deleted file mode 100644 index 540f1c08a6..0000000000 --- a/modules/algebra/include/eigen3/Eigen/MetisSupport +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef IMP_EIGEN_METISSUPPORT_MODULE_H -#define IMP_EIGEN_METISSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -extern "C" { -#include -} - - -/** \ingroup Support_modules - * \defgroup MetisSupport_Module MetisSupport module - * - * \code - * #include - * \endcode - * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). - * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink - */ - - -#include "src/MetisSupport/MetisSupport.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_METISSUPPORT_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/OrderingMethods b/modules/algebra/include/eigen3/Eigen/OrderingMethods deleted file mode 100644 index 406e273cb5..0000000000 --- a/modules/algebra/include/eigen3/Eigen/OrderingMethods +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef IMP_EIGEN_ORDERINGMETHODS_MODULE_H -#define IMP_EIGEN_ORDERINGMETHODS_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** - * \defgroup OrderingMethods_Module OrderingMethods module - * - * This module is currently for internal use only - * - * It defines various built-in and external ordering methods for sparse matrices. - * They are typically used to reduce the number of elements during - * the sparse matrix decomposition (LLT, LU, QR). - * Precisely, in a preprocessing step, a permutation matrix P is computed using - * those ordering methods and applied to the columns of the matrix. - * Using for instance the sparse Cholesky decomposition, it is expected that - * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A). - * - * - * Usage : - * \code - * #include - * \endcode - * - * A simple usage is as a template parameter in the sparse decomposition classes : - * - * \code - * SparseLU > solver; - * \endcode - * - * \code - * SparseQR > solver; - * \endcode - * - * It is possible as well to call directly a particular ordering method for your own purpose, - * \code - * AMDOrdering ordering; - * PermutationMatrix perm; - * SparseMatrix A; - * //Fill the matrix ... - * - * ordering(A, perm); // Call AMD - * \endcode - * - * \note Some of these methods (like AMD or METIS), need the sparsity pattern - * of the input matrix to be symmetric. When the matrix is structurally unsymmetric, - * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method. - * If your matrix is already symmetric (at leat in structure), you can avoid that - * by calling the method with a SelfAdjointView type. - * - * \code - * // Call the ordering on the pattern of the lower triangular matrix A - * ordering(A.selfadjointView(), perm); - * \endcode - */ - -#ifndef IMP_EIGEN_MPL2_ONLY -#include "src/OrderingMethods/Amd.h" -#endif - -#include "src/OrderingMethods/Ordering.h" -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_ORDERINGMETHODS_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/PaStiXSupport b/modules/algebra/include/eigen3/Eigen/PaStiXSupport deleted file mode 100644 index fb3a1df521..0000000000 --- a/modules/algebra/include/eigen3/Eigen/PaStiXSupport +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef IMP_EIGEN_PASTIXSUPPORT_MODULE_H -#define IMP_EIGEN_PASTIXSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include -extern "C" { -#include -#include -} - -#ifdef complex -#undef complex -#endif - -/** \ingroup Support_modules - * \defgroup PaStiXSupport_Module PaStiXSupport module - * - * This module provides an interface to the PaSTiX library. - * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. - * It provides the two following main factorization classes: - * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. - * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. - * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). - * - * \code - * #include - * \endcode - * - * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. - * The dependencies depend on how PaSTiX has been compiled. - * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. - * - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" - -#include "src/PaStiXSupport/PaStiXSupport.h" - - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_PASTIXSUPPORT_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/PardisoSupport b/modules/algebra/include/eigen3/Eigen/PardisoSupport deleted file mode 100644 index 3e5a48433c..0000000000 --- a/modules/algebra/include/eigen3/Eigen/PardisoSupport +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef IMP_EIGEN_PARDISOSUPPORT_MODULE_H -#define IMP_EIGEN_PARDISOSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include - -#include - -/** \ingroup Support_modules - * \defgroup PardisoSupport_Module PardisoSupport module - * - * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. - * - * \code - * #include - * \endcode - * - * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. - * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. - * - */ - -#include "src/PardisoSupport/PardisoSupport.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_PARDISOSUPPORT_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/QR b/modules/algebra/include/eigen3/Eigen/QR deleted file mode 100644 index c3849c74d3..0000000000 --- a/modules/algebra/include/eigen3/Eigen/QR +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef IMP_EIGEN_QR_MODULE_H -#define IMP_EIGEN_QR_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include "Cholesky" -#include "Jacobi" -#include "Householder" - -/** \defgroup QR_Module QR module - * - * - * - * This module provides various QR decompositions - * This module also provides some MatrixBase methods, including: - * - MatrixBase::qr(), - * - * \code - * #include - * \endcode - */ - -#include "src/misc/Solve.h" -#include "src/QR/HouseholderQR.h" -#include "src/QR/FullPivHouseholderQR.h" -#include "src/QR/ColPivHouseholderQR.h" -#ifdef IMP_EIGEN_USE_LAPACKE -#include "src/QR/HouseholderQR_MKL.h" -#include "src/QR/ColPivHouseholderQR_MKL.h" -#endif - -#ifdef IMP_EIGEN2_SUPPORT -#include "src/Eigen2Support/QR.h" -#endif - -#include "src/Core/util/ReenableStupidWarnings.h" - -#ifdef IMP_EIGEN2_SUPPORT -#include "Eigenvalues" -#endif - -#endif // IMP_EIGEN_QR_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/modules/algebra/include/eigen3/Eigen/QtAlignedMalloc b/modules/algebra/include/eigen3/Eigen/QtAlignedMalloc deleted file mode 100644 index 6bcd1c4d68..0000000000 --- a/modules/algebra/include/eigen3/Eigen/QtAlignedMalloc +++ /dev/null @@ -1,34 +0,0 @@ - -#ifndef IMP_EIGEN_QTMALLOC_MODULE_H -#define IMP_EIGEN_QTMALLOC_MODULE_H - -#include "Core" - -#if (!IMP_EIGEN_MALLOC_ALREADY_ALIGNED) - -#include "src/Core/util/DisableStupidWarnings.h" - -void *qMalloc(size_t size) -{ - return IMP_Eigen::internal::aligned_malloc(size); -} - -void qFree(void *ptr) -{ - IMP_Eigen::internal::aligned_free(ptr); -} - -void *qRealloc(void *ptr, size_t size) -{ - void* newPtr = IMP_Eigen::internal::aligned_malloc(size); - memcpy(newPtr, ptr, size); - IMP_Eigen::internal::aligned_free(ptr); - return newPtr; -} - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif - -#endif // IMP_EIGEN_QTMALLOC_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/modules/algebra/include/eigen3/Eigen/SPQRSupport b/modules/algebra/include/eigen3/Eigen/SPQRSupport deleted file mode 100644 index c7dec27f91..0000000000 --- a/modules/algebra/include/eigen3/Eigen/SPQRSupport +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef IMP_EIGEN_SPQRSUPPORT_MODULE_H -#define IMP_EIGEN_SPQRSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include "SuiteSparseQR.hpp" - -/** \ingroup Support_modules - * \defgroup SPQRSupport_Module SuiteSparseQR module - * - * This module provides an interface to the SPQR library, which is part of the suitesparse package. - * - * \code - * #include - * \endcode - * - * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). - * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules - * - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" -#include "src/CholmodSupport/CholmodSupport.h" -#include "src/SPQRSupport/SuiteSparseQRSupport.h" - -#endif diff --git a/modules/algebra/include/eigen3/Eigen/SVD b/modules/algebra/include/eigen3/Eigen/SVD deleted file mode 100644 index b3141521d5..0000000000 --- a/modules/algebra/include/eigen3/Eigen/SVD +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef IMP_EIGEN_SVD_MODULE_H -#define IMP_EIGEN_SVD_MODULE_H - -#include "QR" -#include "Householder" -#include "Jacobi" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** \defgroup SVD_Module SVD module - * - * - * - * This module provides SVD decomposition for matrices (both real and complex). - * This decomposition is accessible via the following MatrixBase method: - * - MatrixBase::jacobiSvd() - * - * \code - * #include - * \endcode - */ - -#include "src/misc/Solve.h" -#include "src/SVD/JacobiSVD.h" -#if defined(IMP_EIGEN_USE_LAPACKE) && !defined(IMP_EIGEN_USE_LAPACKE_STRICT) -#include "src/SVD/JacobiSVD_MKL.h" -#endif -#include "src/SVD/UpperBidiagonalization.h" - -#ifdef IMP_EIGEN2_SUPPORT -#include "src/Eigen2Support/SVD.h" -#endif - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_SVD_MODULE_H -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/modules/algebra/include/eigen3/Eigen/Sparse b/modules/algebra/include/eigen3/Eigen/Sparse deleted file mode 100644 index 484ec8f1fe..0000000000 --- a/modules/algebra/include/eigen3/Eigen/Sparse +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef IMP_EIGEN_SPARSE_MODULE_H -#define IMP_EIGEN_SPARSE_MODULE_H - -/** \defgroup Sparse_Module Sparse meta-module - * - * Meta-module including all related modules: - * - \ref SparseCore_Module - * - \ref OrderingMethods_Module - * - \ref SparseCholesky_Module - * - \ref SparseLU_Module - * - \ref SparseQR_Module - * - \ref IterativeLinearSolvers_Module - * - * \code - * #include - * \endcode - */ - -#include "SparseCore" -#include "OrderingMethods" -#include "SparseCholesky" -#include "SparseLU" -#include "SparseQR" -#include "IterativeLinearSolvers" - -#endif // IMP_EIGEN_SPARSE_MODULE_H - diff --git a/modules/algebra/include/eigen3/Eigen/SparseCholesky b/modules/algebra/include/eigen3/Eigen/SparseCholesky deleted file mode 100644 index e124da8a9d..0000000000 --- a/modules/algebra/include/eigen3/Eigen/SparseCholesky +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2013 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_SPARSECHOLESKY_MODULE_H -#define IMP_EIGEN_SPARSECHOLESKY_MODULE_H - -#include "SparseCore" -#include "OrderingMethods" - -#include "src/Core/util/DisableStupidWarnings.h" - -/** - * \defgroup SparseCholesky_Module SparseCholesky module - * - * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. - * Those decompositions are accessible via the following classes: - * - SimplicialLLt, - * - SimplicialLDLt - * - * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. - * - * \code - * #include - * \endcode - */ - -#ifdef IMP_EIGEN_MPL2_ONLY -#error The SparseCholesky module has nothing to offer in MPL2 only mode -#endif - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" -#include "src/SparseCholesky/SimplicialCholesky.h" - -#ifndef IMP_EIGEN_MPL2_ONLY -#include "src/SparseCholesky/SimplicialCholesky_impl.h" -#endif - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_SPARSECHOLESKY_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/SparseCore b/modules/algebra/include/eigen3/Eigen/SparseCore deleted file mode 100644 index d7ff286de4..0000000000 --- a/modules/algebra/include/eigen3/Eigen/SparseCore +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef IMP_EIGEN_SPARSECORE_MODULE_H -#define IMP_EIGEN_SPARSECORE_MODULE_H - -#include "Core" - -#include "src/Core/util/DisableStupidWarnings.h" - -#include -#include -#include -#include -#include - -/** - * \defgroup SparseCore_Module SparseCore module - * - * This module provides a sparse matrix representation, and basic associated matrix manipulations - * and operations. - * - * See the \ref TutorialSparse "Sparse tutorial" - * - * \code - * #include - * \endcode - * - * This module depends on: Core. - */ - -namespace IMP_Eigen { - -/** The type used to identify a general sparse storage. */ -struct Sparse {}; - -} - -#include "src/SparseCore/SparseUtil.h" -#include "src/SparseCore/SparseMatrixBase.h" -#include "src/SparseCore/CompressedStorage.h" -#include "src/SparseCore/AmbiVector.h" -#include "src/SparseCore/SparseMatrix.h" -#include "src/SparseCore/MappedSparseMatrix.h" -#include "src/SparseCore/SparseVector.h" -#include "src/SparseCore/SparseBlock.h" -#include "src/SparseCore/SparseTranspose.h" -#include "src/SparseCore/SparseCwiseUnaryOp.h" -#include "src/SparseCore/SparseCwiseBinaryOp.h" -#include "src/SparseCore/SparseDot.h" -#include "src/SparseCore/SparsePermutation.h" -#include "src/SparseCore/SparseRedux.h" -#include "src/SparseCore/SparseFuzzy.h" -#include "src/SparseCore/ConservativeSparseSparseProduct.h" -#include "src/SparseCore/SparseSparseProductWithPruning.h" -#include "src/SparseCore/SparseProduct.h" -#include "src/SparseCore/SparseDenseProduct.h" -#include "src/SparseCore/SparseDiagonalProduct.h" -#include "src/SparseCore/SparseTriangularView.h" -#include "src/SparseCore/SparseSelfAdjointView.h" -#include "src/SparseCore/TriangularSolver.h" -#include "src/SparseCore/SparseView.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_SPARSECORE_MODULE_H - diff --git a/modules/algebra/include/eigen3/Eigen/SparseLU b/modules/algebra/include/eigen3/Eigen/SparseLU deleted file mode 100644 index b85403ead3..0000000000 --- a/modules/algebra/include/eigen3/Eigen/SparseLU +++ /dev/null @@ -1,49 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_SPARSELU_MODULE_H -#define IMP_EIGEN_SPARSELU_MODULE_H - -#include "SparseCore" - -/** - * \defgroup SparseLU_Module SparseLU module - * This module defines a supernodal factorization of general sparse matrices. - * The code is fully optimized for supernode-panel updates with specialized kernels. - * Please, see the documentation of the SparseLU class for more details. - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" - -// Ordering interface -#include "OrderingMethods" - -#include "src/SparseLU/SparseLU_gemm_kernel.h" - -#include "src/SparseLU/SparseLU_Structs.h" -#include "src/SparseLU/SparseLU_SupernodalMatrix.h" -#include "src/SparseLU/SparseLUImpl.h" -#include "src/SparseCore/SparseColEtree.h" -#include "src/SparseLU/SparseLU_Memory.h" -#include "src/SparseLU/SparseLU_heap_relax_snode.h" -#include "src/SparseLU/SparseLU_relax_snode.h" -#include "src/SparseLU/SparseLU_pivotL.h" -#include "src/SparseLU/SparseLU_panel_dfs.h" -#include "src/SparseLU/SparseLU_kernel_bmod.h" -#include "src/SparseLU/SparseLU_panel_bmod.h" -#include "src/SparseLU/SparseLU_column_dfs.h" -#include "src/SparseLU/SparseLU_column_bmod.h" -#include "src/SparseLU/SparseLU_copy_to_ucol.h" -#include "src/SparseLU/SparseLU_pruneL.h" -#include "src/SparseLU/SparseLU_Utils.h" -#include "src/SparseLU/SparseLU.h" - -#endif // IMP_EIGEN_SPARSELU_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/SparseQR b/modules/algebra/include/eigen3/Eigen/SparseQR deleted file mode 100644 index 3253ebd5de..0000000000 --- a/modules/algebra/include/eigen3/Eigen/SparseQR +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef IMP_EIGEN_SPARSEQR_MODULE_H -#define IMP_EIGEN_SPARSEQR_MODULE_H - -#include "SparseCore" -#include "OrderingMethods" -#include "src/Core/util/DisableStupidWarnings.h" - -/** \defgroup SparseQR_Module SparseQR module - * \brief Provides QR decomposition for sparse matrices - * - * This module provides a simplicial version of the left-looking Sparse QR decomposition. - * The columns of the input matrix should be reordered to limit the fill-in during the - * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. - * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list - * of built-in and external ordering methods. - * - * \code - * #include - * \endcode - * - * - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" - -#include "OrderingMethods" -#include "src/SparseCore/SparseColEtree.h" -#include "src/SparseQR/SparseQR.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif diff --git a/modules/algebra/include/eigen3/Eigen/StdDeque b/modules/algebra/include/eigen3/Eigen/StdDeque deleted file mode 100644 index 90a8d873bd..0000000000 --- a/modules/algebra/include/eigen3/Eigen/StdDeque +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// Copyright (C) 2009 Hauke Heibel -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_STDDEQUE_MODULE_H -#define IMP_EIGEN_STDDEQUE_MODULE_H - -#include "Core" -#include - -#if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ - -#define IMP_EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) - -#else - -#include "src/StlSupport/StdDeque.h" - -#endif - -#endif // IMP_EIGEN_STDDEQUE_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/StdList b/modules/algebra/include/eigen3/Eigen/StdList deleted file mode 100644 index 1655a1ccf0..0000000000 --- a/modules/algebra/include/eigen3/Eigen/StdList +++ /dev/null @@ -1,26 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Hauke Heibel -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_STDLIST_MODULE_H -#define IMP_EIGEN_STDLIST_MODULE_H - -#include "Core" -#include - -#if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ - -#define IMP_EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) - -#else - -#include "src/StlSupport/StdList.h" - -#endif - -#endif // IMP_EIGEN_STDLIST_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/StdVector b/modules/algebra/include/eigen3/Eigen/StdVector deleted file mode 100644 index 7986d6ccf7..0000000000 --- a/modules/algebra/include/eigen3/Eigen/StdVector +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// Copyright (C) 2009 Hauke Heibel -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_STDVECTOR_MODULE_H -#define IMP_EIGEN_STDVECTOR_MODULE_H - -#include "Core" -#include - -#if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ - -#define IMP_EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) - -#else - -#include "src/StlSupport/StdVector.h" - -#endif - -#endif // IMP_EIGEN_STDVECTOR_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/SuperLUSupport b/modules/algebra/include/eigen3/Eigen/SuperLUSupport deleted file mode 100644 index 0d309fc4bf..0000000000 --- a/modules/algebra/include/eigen3/Eigen/SuperLUSupport +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef IMP_EIGEN_SUPERLUSUPPORT_MODULE_H -#define IMP_EIGEN_SUPERLUSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -#ifdef EMPTY -#define IMP_EIGEN_EMPTY_WAS_ALREADY_DEFINED -#endif - -typedef int int_t; -#include -#include -#include - -// slu_util.h defines a preprocessor token named EMPTY which is really polluting, -// so we remove it in favor of a SUPERLU_EMPTY token. -// If EMPTY was already defined then we don't undef it. - -#if defined(IMP_EIGEN_EMPTY_WAS_ALREADY_DEFINED) -# undef IMP_EIGEN_EMPTY_WAS_ALREADY_DEFINED -#elif defined(EMPTY) -# undef EMPTY -#endif - -#define SUPERLU_EMPTY (-1) - -namespace IMP_Eigen { struct SluMatrix; } - -/** \ingroup Support_modules - * \defgroup SuperLUSupport_Module SuperLUSupport module - * - * This module provides an interface to the SuperLU library. - * It provides the following factorization class: - * - class SuperLU: a supernodal sequential LU factorization. - * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). - * - * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. - * - * \code - * #include - * \endcode - * - * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies. - * The dependencies depend on how superlu has been compiled. - * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. - * - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" - -#include "src/SuperLUSupport/SuperLUSupport.h" - - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_SUPERLUSUPPORT_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/UmfPackSupport b/modules/algebra/include/eigen3/Eigen/UmfPackSupport deleted file mode 100644 index 94ec636f2d..0000000000 --- a/modules/algebra/include/eigen3/Eigen/UmfPackSupport +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef IMP_EIGEN_UMFPACKSUPPORT_MODULE_H -#define IMP_EIGEN_UMFPACKSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -extern "C" { -#include -} - -/** \ingroup Support_modules - * \defgroup UmfPackSupport_Module UmfPackSupport module - * - * This module provides an interface to the UmfPack library which is part of the suitesparse package. - * It provides the following factorization class: - * - class UmfPackLU: a multifrontal sequential LU factorization. - * - * \code - * #include - * \endcode - * - * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. - * The dependencies depend on how umfpack has been compiled. - * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. - * - */ - -#include "src/misc/Solve.h" -#include "src/misc/SparseSolve.h" - -#include "src/UmfPackSupport/UmfPackSupport.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // IMP_EIGEN_UMFPACKSUPPORT_MODULE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Cholesky/LDLT.h b/modules/algebra/include/eigen3/Eigen/src/Cholesky/LDLT.h deleted file mode 100644 index f9b7a37d10..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Cholesky/LDLT.h +++ /dev/null @@ -1,611 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2011 Gael Guennebaud -// Copyright (C) 2009 Keir Mierle -// Copyright (C) 2009 Benoit Jacob -// Copyright (C) 2011 Timothy E. Holy -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_LDLT_H -#define IMP_EIGEN_LDLT_H - -namespace IMP_Eigen { - -namespace internal { - template struct LDLT_Traits; - - // PositiveSemiDef means positive semi-definite and non-zero; same for NegativeSemiDef - enum SignMatrix { PositiveSemiDef, NegativeSemiDef, ZeroSign, Indefinite }; -} - -/** \ingroup Cholesky_Module - * - * \class LDLT - * - * \brief Robust Cholesky decomposition of a matrix with pivoting - * - * \param MatrixType the type of the matrix of which to compute the LDL^T Cholesky decomposition - * \param UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper. - * The other triangular part won't be read. - * - * Perform a robust Cholesky decomposition of a positive semidefinite or negative semidefinite - * matrix \f$ A \f$ such that \f$ A = P^TLDL^*P \f$, where P is a permutation matrix, L - * is lower triangular with a unit diagonal and D is a diagonal matrix. - * - * The decomposition uses pivoting to ensure stability, so that L will have - * zeros in the bottom right rank(A) - n submatrix. Avoiding the square root - * on D also stabilizes the computation. - * - * Remember that Cholesky decompositions are not rank-revealing. Also, do not use a Cholesky - * decomposition to determine whether a system of equations has a solution. - * - * \sa MatrixBase::ldlt(), class LLT - */ -template class LDLT -{ - public: - typedef _MatrixType MatrixType; - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - Options = MatrixType::Options & ~RowMajorBit, // these are the options for the TmpMatrixType, we need a ColMajor matrix here! - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - UpLo = _UpLo - }; - typedef typename MatrixType::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; - typedef typename MatrixType::Index Index; - typedef Matrix TmpMatrixType; - - typedef Transpositions TranspositionType; - typedef PermutationMatrix PermutationType; - - typedef internal::LDLT_Traits Traits; - - /** \brief Default Constructor. - * - * The default constructor is useful in cases in which the user intends to - * perform decompositions via LDLT::compute(const MatrixType&). - */ - LDLT() - : m_matrix(), - m_transpositions(), - m_sign(internal::ZeroSign), - m_isInitialized(false) - {} - - /** \brief Default Constructor with memory preallocation - * - * Like the default constructor but with preallocation of the internal data - * according to the specified problem \a size. - * \sa LDLT() - */ - LDLT(Index size) - : m_matrix(size, size), - m_transpositions(size), - m_temporary(size), - m_sign(internal::ZeroSign), - m_isInitialized(false) - {} - - /** \brief Constructor with decomposition - * - * This calculates the decomposition for the input \a matrix. - * \sa LDLT(Index size) - */ - LDLT(const MatrixType& matrix) - : m_matrix(matrix.rows(), matrix.cols()), - m_transpositions(matrix.rows()), - m_temporary(matrix.rows()), - m_sign(internal::ZeroSign), - m_isInitialized(false) - { - compute(matrix); - } - - /** Clear any existing decomposition - * \sa rankUpdate(w,sigma) - */ - void setZero() - { - m_isInitialized = false; - } - - /** \returns a view of the upper triangular matrix U */ - inline typename Traits::MatrixU matrixU() const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return Traits::getU(m_matrix); - } - - /** \returns a view of the lower triangular matrix L */ - inline typename Traits::MatrixL matrixL() const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return Traits::getL(m_matrix); - } - - /** \returns the permutation matrix P as a transposition sequence. - */ - inline const TranspositionType& transpositionsP() const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return m_transpositions; - } - - /** \returns the coefficients of the diagonal matrix D */ - inline Diagonal vectorD() const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return m_matrix.diagonal(); - } - - /** \returns true if the matrix is positive (semidefinite) */ - inline bool isPositive() const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return m_sign == internal::PositiveSemiDef || m_sign == internal::ZeroSign; - } - - #ifdef IMP_EIGEN2_SUPPORT - inline bool isPositiveDefinite() const - { - return isPositive(); - } - #endif - - /** \returns true if the matrix is negative (semidefinite) */ - inline bool isNegative(void) const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return m_sign == internal::NegativeSemiDef || m_sign == internal::ZeroSign; - } - - /** \returns a solution x of \f$ A x = b \f$ using the current decomposition of A. - * - * This function also supports in-place solves using the syntax x = decompositionObject.solve(x) . - * - * \note_about_checking_solutions - * - * More precisely, this method solves \f$ A x = b \f$ using the decomposition \f$ A = P^T L D L^* P \f$ - * by solving the systems \f$ P^T y_1 = b \f$, \f$ L y_2 = y_1 \f$, \f$ D y_3 = y_2 \f$, - * \f$ L^* y_4 = y_3 \f$ and \f$ P x = y_4 \f$ in succession. If the matrix \f$ A \f$ is singular, then - * \f$ D \f$ will also be singular (all the other matrices are invertible). In that case, the - * least-square solution of \f$ D y_3 = y_2 \f$ is computed. This does not mean that this function - * computes the least-square solution of \f$ A x = b \f$ is \f$ A \f$ is singular. - * - * \sa MatrixBase::ldlt() - */ - template - inline const internal::solve_retval - solve(const MatrixBase& b) const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - imp_eigen_assert(m_matrix.rows()==b.rows() - && "LDLT::solve(): invalid number of rows of the right hand side matrix b"); - return internal::solve_retval(*this, b.derived()); - } - - #ifdef IMP_EIGEN2_SUPPORT - template - bool solve(const MatrixBase& b, ResultType *result) const - { - *result = this->solve(b); - return true; - } - #endif - - template - bool solveInPlace(MatrixBase &bAndX) const; - - LDLT& compute(const MatrixType& matrix); - - template - LDLT& rankUpdate(const MatrixBase& w, const RealScalar& alpha=1); - - /** \returns the internal LDLT decomposition matrix - * - * TODO: document the storage layout - */ - inline const MatrixType& matrixLDLT() const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return m_matrix; - } - - MatrixType reconstructedMatrix() const; - - inline Index rows() const { return m_matrix.rows(); } - inline Index cols() const { return m_matrix.cols(); } - - /** \brief Reports whether previous computation was successful. - * - * \returns \c Success if computation was succesful, - * \c NumericalIssue if the matrix.appears to be negative. - */ - ComputationInfo info() const - { - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - return Success; - } - - protected: - - static void check_template_parameters() - { - IMP_EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar); - } - - /** \internal - * Used to compute and store the Cholesky decomposition A = L D L^* = U^* D U. - * The strict upper part is used during the decomposition, the strict lower - * part correspond to the coefficients of L (its diagonal is equal to 1 and - * is not stored), and the diagonal entries correspond to D. - */ - MatrixType m_matrix; - TranspositionType m_transpositions; - TmpMatrixType m_temporary; - internal::SignMatrix m_sign; - bool m_isInitialized; -}; - -namespace internal { - -template struct ldlt_inplace; - -template<> struct ldlt_inplace -{ - template - static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign) - { - using std::abs; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - imp_eigen_assert(mat.rows()==mat.cols()); - const Index size = mat.rows(); - - if (size <= 1) - { - transpositions.setIdentity(); - if (numext::real(mat.coeff(0,0)) > 0) sign = PositiveSemiDef; - else if (numext::real(mat.coeff(0,0)) < 0) sign = NegativeSemiDef; - else sign = ZeroSign; - return true; - } - - for (Index k = 0; k < size; ++k) - { - // Find largest diagonal element - Index index_of_biggest_in_corner; - mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner); - index_of_biggest_in_corner += k; - - transpositions.coeffRef(k) = index_of_biggest_in_corner; - if(k != index_of_biggest_in_corner) - { - // apply the transposition while taking care to consider only - // the lower triangular part - Index s = size-index_of_biggest_in_corner-1; // trailing size after the biggest element - mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k)); - mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s)); - std::swap(mat.coeffRef(k,k),mat.coeffRef(index_of_biggest_in_corner,index_of_biggest_in_corner)); - for(int i=k+1;i::IsComplex) - mat.coeffRef(index_of_biggest_in_corner,k) = numext::conj(mat.coeff(index_of_biggest_in_corner,k)); - } - - // partition the matrix: - // A00 | - | - - // lu = A10 | A11 | - - // A20 | A21 | A22 - Index rs = size - k - 1; - Block A21(mat,k+1,k,rs,1); - Block A10(mat,k,0,1,k); - Block A20(mat,k+1,0,rs,k); - - if(k>0) - { - temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint(); - mat.coeffRef(k,k) -= (A10 * temp.head(k)).value(); - if(rs>0) - A21.noalias() -= A20 * temp.head(k); - } - - // In some previous versions of Eigen (e.g., 3.2.1), the scaling was omitted if the pivot - // was smaller than the cutoff value. However, soince LDLT is not rank-revealing - // we should only make sure we do not introduce INF or NaN values. - // LAPACK also uses 0 as the cutoff value. - RealScalar realAkk = numext::real(mat.coeffRef(k,k)); - if((rs>0) && (abs(realAkk) > RealScalar(0))) - A21 /= realAkk; - - if (sign == PositiveSemiDef) { - if (realAkk < 0) sign = Indefinite; - } else if (sign == NegativeSemiDef) { - if (realAkk > 0) sign = Indefinite; - } else if (sign == ZeroSign) { - if (realAkk > 0) sign = PositiveSemiDef; - else if (realAkk < 0) sign = NegativeSemiDef; - } - } - - return true; - } - - // Reference for the algorithm: Davis and Hager, "Multiple Rank - // Modifications of a Sparse Cholesky Factorization" (Algorithm 1) - // Trivial rearrangements of their computations (Timothy E. Holy) - // allow their algorithm to work for rank-1 updates even if the - // original matrix is not of full rank. - // Here only rank-1 updates are implemented, to reduce the - // requirement for intermediate storage and improve accuracy - template - static bool updateInPlace(MatrixType& mat, MatrixBase& w, const typename MatrixType::RealScalar& sigma=1) - { - using numext::isfinite; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - - const Index size = mat.rows(); - imp_eigen_assert(mat.cols() == size && w.size()==size); - - RealScalar alpha = 1; - - // Apply the update - for (Index j = 0; j < size; j++) - { - // Check for termination due to an original decomposition of low-rank - if (!(isfinite)(alpha)) - break; - - // Update the diagonal terms - RealScalar dj = numext::real(mat.coeff(j,j)); - Scalar wj = w.coeff(j); - RealScalar swj2 = sigma*numext::abs2(wj); - RealScalar gamma = dj*alpha + swj2; - - mat.coeffRef(j,j) += swj2/alpha; - alpha += swj2/dj; - - - // Update the terms of L - Index rs = size-j-1; - w.tail(rs) -= wj * mat.col(j).tail(rs); - if(gamma != 0) - mat.col(j).tail(rs) += (sigma*numext::conj(wj)/gamma)*w.tail(rs); - } - return true; - } - - template - static bool update(MatrixType& mat, const TranspositionType& transpositions, Workspace& tmp, const WType& w, const typename MatrixType::RealScalar& sigma=1) - { - // Apply the permutation to the input w - tmp = transpositions * w; - - return ldlt_inplace::updateInPlace(mat,tmp,sigma); - } -}; - -template<> struct ldlt_inplace -{ - template - static IMP_EIGEN_STRONG_INLINE bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign) - { - Transpose matt(mat); - return ldlt_inplace::unblocked(matt, transpositions, temp, sign); - } - - template - static IMP_EIGEN_STRONG_INLINE bool update(MatrixType& mat, TranspositionType& transpositions, Workspace& tmp, WType& w, const typename MatrixType::RealScalar& sigma=1) - { - Transpose matt(mat); - return ldlt_inplace::update(matt, transpositions, tmp, w.conjugate(), sigma); - } -}; - -template struct LDLT_Traits -{ - typedef const TriangularView MatrixL; - typedef const TriangularView MatrixU; - static inline MatrixL getL(const MatrixType& m) { return m; } - static inline MatrixU getU(const MatrixType& m) { return m.adjoint(); } -}; - -template struct LDLT_Traits -{ - typedef const TriangularView MatrixL; - typedef const TriangularView MatrixU; - static inline MatrixL getL(const MatrixType& m) { return m.adjoint(); } - static inline MatrixU getU(const MatrixType& m) { return m; } -}; - -} // end namespace internal - -/** Compute / recompute the LDLT decomposition A = L D L^* = U^* D U of \a matrix - */ -template -LDLT& LDLT::compute(const MatrixType& a) -{ - check_template_parameters(); - - imp_eigen_assert(a.rows()==a.cols()); - const Index size = a.rows(); - - m_matrix = a; - - m_transpositions.resize(size); - m_isInitialized = false; - m_temporary.resize(size); - m_sign = internal::ZeroSign; - - internal::ldlt_inplace::unblocked(m_matrix, m_transpositions, m_temporary, m_sign); - - m_isInitialized = true; - return *this; -} - -/** Update the LDLT decomposition: given A = L D L^T, efficiently compute the decomposition of A + sigma w w^T. - * \param w a vector to be incorporated into the decomposition. - * \param sigma a scalar, +1 for updates and -1 for "downdates," which correspond to removing previously-added column vectors. Optional; default value is +1. - * \sa setZero() - */ -template -template -LDLT& LDLT::rankUpdate(const MatrixBase& w, const typename LDLT::RealScalar& sigma) -{ - const Index size = w.rows(); - if (m_isInitialized) - { - imp_eigen_assert(m_matrix.rows()==size); - } - else - { - m_matrix.resize(size,size); - m_matrix.setZero(); - m_transpositions.resize(size); - for (Index i = 0; i < size; i++) - m_transpositions.coeffRef(i) = i; - m_temporary.resize(size); - m_sign = sigma>=0 ? internal::PositiveSemiDef : internal::NegativeSemiDef; - m_isInitialized = true; - } - - internal::ldlt_inplace::update(m_matrix, m_transpositions, m_temporary, w, sigma); - - return *this; -} - -namespace internal { -template -struct solve_retval, Rhs> - : solve_retval_base, Rhs> -{ - typedef LDLT<_MatrixType,_UpLo> LDLTType; - IMP_EIGEN_MAKE_SOLVE_HELPERS(LDLTType,Rhs) - - template void evalTo(Dest& dst) const - { - imp_eigen_assert(rhs().rows() == dec().matrixLDLT().rows()); - // dst = P b - dst = dec().transpositionsP() * rhs(); - - // dst = L^-1 (P b) - dec().matrixL().solveInPlace(dst); - - // dst = D^-1 (L^-1 P b) - // more precisely, use pseudo-inverse of D (see bug 241) - using std::abs; - using std::max; - typedef typename LDLTType::MatrixType MatrixType; - typedef typename LDLTType::RealScalar RealScalar; - const typename Diagonal::RealReturnType vectorD(dec().vectorD()); - // In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon - // as motivated by LAPACK's xGELSS: - // RealScalar tolerance = (max)(vectorD.array().abs().maxCoeff() *NumTraits::epsilon(),RealScalar(1) / NumTraits::highest()); - // However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest - // diagonal element is not well justified and to numerical issues in some cases. - // Moreover, Lapack's xSYTRS routines use 0 for the tolerance. - RealScalar tolerance = RealScalar(1) / NumTraits::highest(); - - for (Index i = 0; i < vectorD.size(); ++i) { - if(abs(vectorD(i)) > tolerance) - dst.row(i) /= vectorD(i); - else - dst.row(i).setZero(); - } - - // dst = L^-T (D^-1 L^-1 P b) - dec().matrixU().solveInPlace(dst); - - // dst = P^-1 (L^-T D^-1 L^-1 P b) = A^-1 b - dst = dec().transpositionsP().transpose() * dst; - } -}; -} - -/** \internal use x = ldlt_object.solve(x); - * - * This is the \em in-place version of solve(). - * - * \param bAndX represents both the right-hand side matrix b and result x. - * - * \returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD. - * - * This version avoids a copy when the right hand side matrix b is not - * needed anymore. - * - * \sa LDLT::solve(), MatrixBase::ldlt() - */ -template -template -bool LDLT::solveInPlace(MatrixBase &bAndX) const -{ - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - imp_eigen_assert(m_matrix.rows() == bAndX.rows()); - - bAndX = this->solve(bAndX); - - return true; -} - -/** \returns the matrix represented by the decomposition, - * i.e., it returns the product: P^T L D L^* P. - * This function is provided for debug purpose. */ -template -MatrixType LDLT::reconstructedMatrix() const -{ - imp_eigen_assert(m_isInitialized && "LDLT is not initialized."); - const Index size = m_matrix.rows(); - MatrixType res(size,size); - - // P - res.setIdentity(); - res = transpositionsP() * res; - // L^* P - res = matrixU() * res; - // D(L^*P) - res = vectorD().real().asDiagonal() * res; - // L(DL^*P) - res = matrixL() * res; - // P^T (LDL^*P) - res = transpositionsP().transpose() * res; - - return res; -} - -/** \cholesky_module - * \returns the Cholesky decomposition with full pivoting without square root of \c *this - */ -template -inline const LDLT::PlainObject, UpLo> -SelfAdjointView::ldlt() const -{ - return LDLT(m_matrix); -} - -/** \cholesky_module - * \returns the Cholesky decomposition with full pivoting without square root of \c *this - */ -template -inline const LDLT::PlainObject> -MatrixBase::ldlt() const -{ - return LDLT(derived()); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_LDLT_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT.h b/modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT.h deleted file mode 100644 index b6f10aec1e..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT.h +++ /dev/null @@ -1,498 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_LLT_H -#define IMP_EIGEN_LLT_H - -namespace IMP_Eigen { - -namespace internal{ -template struct LLT_Traits; -} - -/** \ingroup Cholesky_Module - * - * \class LLT - * - * \brief Standard Cholesky decomposition (LL^T) of a matrix and associated features - * - * \param MatrixType the type of the matrix of which we are computing the LL^T Cholesky decomposition - * \param UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper. - * The other triangular part won't be read. - * - * This class performs a LL^T Cholesky decomposition of a symmetric, positive definite - * matrix A such that A = LL^* = U^*U, where L is lower triangular. - * - * While the Cholesky decomposition is particularly useful to solve selfadjoint problems like D^*D x = b, - * for that purpose, we recommend the Cholesky decomposition without square root which is more stable - * and even faster. Nevertheless, this standard Cholesky decomposition remains useful in many other - * situations like generalised eigen problems with hermitian matrices. - * - * Remember that Cholesky decompositions are not rank-revealing. This LLT decomposition is only stable on positive definite matrices, - * use LDLT instead for the semidefinite case. Also, do not use a Cholesky decomposition to determine whether a system of equations - * has a solution. - * - * Example: \include LLT_example.cpp - * Output: \verbinclude LLT_example.out - * - * \sa MatrixBase::llt(), class LDLT - */ - /* HEY THIS DOX IS DISABLED BECAUSE THERE's A BUG EITHER HERE OR IN LDLT ABOUT THAT (OR BOTH) - * Note that during the decomposition, only the upper triangular part of A is considered. Therefore, - * the strict lower part does not have to store correct values. - */ -template class LLT -{ - public: - typedef _MatrixType MatrixType; - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - Options = MatrixType::Options, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime - }; - typedef typename MatrixType::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; - typedef typename MatrixType::Index Index; - - enum { - PacketSize = internal::packet_traits::size, - AlignmentMask = int(PacketSize)-1, - UpLo = _UpLo - }; - - typedef internal::LLT_Traits Traits; - - /** - * \brief Default Constructor. - * - * The default constructor is useful in cases in which the user intends to - * perform decompositions via LLT::compute(const MatrixType&). - */ - LLT() : m_matrix(), m_isInitialized(false) {} - - /** \brief Default Constructor with memory preallocation - * - * Like the default constructor but with preallocation of the internal data - * according to the specified problem \a size. - * \sa LLT() - */ - LLT(Index size) : m_matrix(size, size), - m_isInitialized(false) {} - - LLT(const MatrixType& matrix) - : m_matrix(matrix.rows(), matrix.cols()), - m_isInitialized(false) - { - compute(matrix); - } - - /** \returns a view of the upper triangular matrix U */ - inline typename Traits::MatrixU matrixU() const - { - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - return Traits::getU(m_matrix); - } - - /** \returns a view of the lower triangular matrix L */ - inline typename Traits::MatrixL matrixL() const - { - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - return Traits::getL(m_matrix); - } - - /** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A. - * - * Since this LLT class assumes anyway that the matrix A is invertible, the solution - * theoretically exists and is unique regardless of b. - * - * Example: \include LLT_solve.cpp - * Output: \verbinclude LLT_solve.out - * - * \sa solveInPlace(), MatrixBase::llt() - */ - template - inline const internal::solve_retval - solve(const MatrixBase& b) const - { - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - imp_eigen_assert(m_matrix.rows()==b.rows() - && "LLT::solve(): invalid number of rows of the right hand side matrix b"); - return internal::solve_retval(*this, b.derived()); - } - - #ifdef IMP_EIGEN2_SUPPORT - template - bool solve(const MatrixBase& b, ResultType *result) const - { - *result = this->solve(b); - return true; - } - - bool isPositiveDefinite() const { return true; } - #endif - - template - void solveInPlace(MatrixBase &bAndX) const; - - LLT& compute(const MatrixType& matrix); - - /** \returns the LLT decomposition matrix - * - * TODO: document the storage layout - */ - inline const MatrixType& matrixLLT() const - { - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - return m_matrix; - } - - MatrixType reconstructedMatrix() const; - - - /** \brief Reports whether previous computation was successful. - * - * \returns \c Success if computation was succesful, - * \c NumericalIssue if the matrix.appears to be negative. - */ - ComputationInfo info() const - { - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - return m_info; - } - - inline Index rows() const { return m_matrix.rows(); } - inline Index cols() const { return m_matrix.cols(); } - - template - LLT rankUpdate(const VectorType& vec, const RealScalar& sigma = 1); - - protected: - - static void check_template_parameters() - { - IMP_EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar); - } - - /** \internal - * Used to compute and store L - * The strict upper part is not used and even not initialized. - */ - MatrixType m_matrix; - bool m_isInitialized; - ComputationInfo m_info; -}; - -namespace internal { - -template struct llt_inplace; - -template -static typename MatrixType::Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) -{ - using std::sqrt; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef typename MatrixType::ColXpr ColXpr; - typedef typename internal::remove_all::type ColXprCleaned; - typedef typename ColXprCleaned::SegmentReturnType ColXprSegment; - typedef Matrix TempVectorType; - typedef typename TempVectorType::SegmentReturnType TempVecSegment; - - Index n = mat.cols(); - imp_eigen_assert(mat.rows()==n && vec.size()==n); - - TempVectorType temp; - - if(sigma>0) - { - // This version is based on Givens rotations. - // It is faster than the other one below, but only works for updates, - // i.e., for sigma > 0 - temp = sqrt(sigma) * vec; - - for(Index i=0; i g; - g.makeGivens(mat(i,i), -temp(i), &mat(i,i)); - - Index rs = n-i-1; - if(rs>0) - { - ColXprSegment x(mat.col(i).tail(rs)); - TempVecSegment y(temp.tail(rs)); - apply_rotation_in_the_plane(x, y, g); - } - } - } - else - { - temp = vec; - RealScalar beta = 1; - for(Index j=0; j struct llt_inplace -{ - typedef typename NumTraits::Real RealScalar; - template - static typename MatrixType::Index unblocked(MatrixType& mat) - { - using std::sqrt; - typedef typename MatrixType::Index Index; - - imp_eigen_assert(mat.rows()==mat.cols()); - const Index size = mat.rows(); - for(Index k = 0; k < size; ++k) - { - Index rs = size-k-1; // remaining size - - Block A21(mat,k+1,k,rs,1); - Block A10(mat,k,0,1,k); - Block A20(mat,k+1,0,rs,k); - - RealScalar x = numext::real(mat.coeff(k,k)); - if (k>0) x -= A10.squaredNorm(); - if (x<=RealScalar(0)) - return k; - mat.coeffRef(k,k) = x = sqrt(x); - if (k>0 && rs>0) A21.noalias() -= A20 * A10.adjoint(); - if (rs>0) A21 /= x; - } - return -1; - } - - template - static typename MatrixType::Index blocked(MatrixType& m) - { - typedef typename MatrixType::Index Index; - imp_eigen_assert(m.rows()==m.cols()); - Index size = m.rows(); - if(size<32) - return unblocked(m); - - Index blockSize = size/8; - blockSize = (blockSize/16)*16; - blockSize = (std::min)((std::max)(blockSize,Index(8)), Index(128)); - - for (Index k=0; k A11(m,k, k, bs,bs); - Block A21(m,k+bs,k, rs,bs); - Block A22(m,k+bs,k+bs,rs,rs); - - Index ret; - if((ret=unblocked(A11))>=0) return k+ret; - if(rs>0) A11.adjoint().template triangularView().template solveInPlace(A21); - if(rs>0) A22.template selfadjointView().rankUpdate(A21,-1); // bottleneck - } - return -1; - } - - template - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) - { - return IMP_Eigen::internal::llt_rank_update_lower(mat, vec, sigma); - } -}; - -template struct llt_inplace -{ - typedef typename NumTraits::Real RealScalar; - - template - static IMP_EIGEN_STRONG_INLINE typename MatrixType::Index unblocked(MatrixType& mat) - { - Transpose matt(mat); - return llt_inplace::unblocked(matt); - } - template - static IMP_EIGEN_STRONG_INLINE typename MatrixType::Index blocked(MatrixType& mat) - { - Transpose matt(mat); - return llt_inplace::blocked(matt); - } - template - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) - { - Transpose matt(mat); - return llt_inplace::rankUpdate(matt, vec.conjugate(), sigma); - } -}; - -template struct LLT_Traits -{ - typedef const TriangularView MatrixL; - typedef const TriangularView MatrixU; - static inline MatrixL getL(const MatrixType& m) { return m; } - static inline MatrixU getU(const MatrixType& m) { return m.adjoint(); } - static bool inplace_decomposition(MatrixType& m) - { return llt_inplace::blocked(m)==-1; } -}; - -template struct LLT_Traits -{ - typedef const TriangularView MatrixL; - typedef const TriangularView MatrixU; - static inline MatrixL getL(const MatrixType& m) { return m.adjoint(); } - static inline MatrixU getU(const MatrixType& m) { return m; } - static bool inplace_decomposition(MatrixType& m) - { return llt_inplace::blocked(m)==-1; } -}; - -} // end namespace internal - -/** Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of \a matrix - * - * \returns a reference to *this - * - * Example: \include TutorialLinAlgComputeTwice.cpp - * Output: \verbinclude TutorialLinAlgComputeTwice.out - */ -template -LLT& LLT::compute(const MatrixType& a) -{ - check_template_parameters(); - - imp_eigen_assert(a.rows()==a.cols()); - const Index size = a.rows(); - m_matrix.resize(size, size); - m_matrix = a; - - m_isInitialized = true; - bool ok = Traits::inplace_decomposition(m_matrix); - m_info = ok ? Success : NumericalIssue; - - return *this; -} - -/** Performs a rank one update (or dowdate) of the current decomposition. - * If A = LL^* before the rank one update, - * then after it we have LL^* = A + sigma * v v^* where \a v must be a vector - * of same dimension. - */ -template -template -LLT<_MatrixType,_UpLo> LLT<_MatrixType,_UpLo>::rankUpdate(const VectorType& v, const RealScalar& sigma) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorType); - imp_eigen_assert(v.size()==m_matrix.cols()); - imp_eigen_assert(m_isInitialized); - if(internal::llt_inplace::rankUpdate(m_matrix,v,sigma)>=0) - m_info = NumericalIssue; - else - m_info = Success; - - return *this; -} - -namespace internal { -template -struct solve_retval, Rhs> - : solve_retval_base, Rhs> -{ - typedef LLT<_MatrixType,UpLo> LLTType; - IMP_EIGEN_MAKE_SOLVE_HELPERS(LLTType,Rhs) - - template void evalTo(Dest& dst) const - { - dst = rhs(); - dec().solveInPlace(dst); - } -}; -} - -/** \internal use x = llt_object.solve(x); - * - * This is the \em in-place version of solve(). - * - * \param bAndX represents both the right-hand side matrix b and result x. - * - * \returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD. - * - * This version avoids a copy when the right hand side matrix b is not - * needed anymore. - * - * \sa LLT::solve(), MatrixBase::llt() - */ -template -template -void LLT::solveInPlace(MatrixBase &bAndX) const -{ - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - imp_eigen_assert(m_matrix.rows()==bAndX.rows()); - matrixL().solveInPlace(bAndX); - matrixU().solveInPlace(bAndX); -} - -/** \returns the matrix represented by the decomposition, - * i.e., it returns the product: L L^*. - * This function is provided for debug purpose. */ -template -MatrixType LLT::reconstructedMatrix() const -{ - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - return matrixL() * matrixL().adjoint().toDenseMatrix(); -} - -/** \cholesky_module - * \returns the LLT decomposition of \c *this - */ -template -inline const LLT::PlainObject> -MatrixBase::llt() const -{ - return LLT(derived()); -} - -/** \cholesky_module - * \returns the LLT decomposition of \c *this - */ -template -inline const LLT::PlainObject, UpLo> -SelfAdjointView::llt() const -{ - return LLT(m_matrix); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_LLT_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT_MKL.h b/modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT_MKL.h deleted file mode 100644 index 27de322a8a..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Cholesky/LLT_MKL.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (c) 2011, Intel Corporation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors may - be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - ******************************************************************************** - * Content : Eigen bindings to Intel(R) MKL - * LLt decomposition based on LAPACKE_?potrf function. - ******************************************************************************** -*/ - -#ifndef IMP_EIGEN_LLT_MKL_H -#define IMP_EIGEN_LLT_MKL_H - -#include "Eigen/src/Core/util/MKL_support.h" -#include - -namespace IMP_Eigen { - -namespace internal { - -template struct mkl_llt; - -#define IMP_EIGEN_MKL_LLT(EIGTYPE, MKLTYPE, MKLPREFIX) \ -template<> struct mkl_llt \ -{ \ - template \ - static inline typename MatrixType::Index potrf(MatrixType& m, char uplo) \ - { \ - lapack_int matrix_order; \ - lapack_int size, lda, info, StorageOrder; \ - EIGTYPE* a; \ - imp_eigen_assert(m.rows()==m.cols()); \ - /* Set up parameters for ?potrf */ \ - size = m.rows(); \ - StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \ - matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ - a = &(m.coeffRef(0,0)); \ - lda = m.outerStride(); \ -\ - info = LAPACKE_##MKLPREFIX##potrf( matrix_order, uplo, size, (MKLTYPE*)a, lda ); \ - info = (info==0) ? -1 : info>0 ? info-1 : size; \ - return info; \ - } \ -}; \ -template<> struct llt_inplace \ -{ \ - template \ - static typename MatrixType::Index blocked(MatrixType& m) \ - { \ - return mkl_llt::potrf(m, 'L'); \ - } \ - template \ - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \ - { return IMP_Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \ -}; \ -template<> struct llt_inplace \ -{ \ - template \ - static typename MatrixType::Index blocked(MatrixType& m) \ - { \ - return mkl_llt::potrf(m, 'U'); \ - } \ - template \ - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \ - { \ - Transpose matt(mat); \ - return llt_inplace::rankUpdate(matt, vec.conjugate(), sigma); \ - } \ -}; - -IMP_EIGEN_MKL_LLT(double, double, d) -IMP_EIGEN_MKL_LLT(float, float, s) -IMP_EIGEN_MKL_LLT(dcomplex, MKL_Complex16, z) -IMP_EIGEN_MKL_LLT(scomplex, MKL_Complex8, c) - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_LLT_MKL_H diff --git a/modules/algebra/include/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h b/modules/algebra/include/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h deleted file mode 100644 index 6952159b96..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +++ /dev/null @@ -1,607 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_CHOLMODSUPPORT_H -#define IMP_EIGEN_CHOLMODSUPPORT_H - -namespace IMP_Eigen { - -namespace internal { - -template -void cholmod_configure_matrix(CholmodType& mat) -{ - if (internal::is_same::value) - { - mat.xtype = CHOLMOD_REAL; - mat.dtype = CHOLMOD_SINGLE; - } - else if (internal::is_same::value) - { - mat.xtype = CHOLMOD_REAL; - mat.dtype = CHOLMOD_DOUBLE; - } - else if (internal::is_same >::value) - { - mat.xtype = CHOLMOD_COMPLEX; - mat.dtype = CHOLMOD_SINGLE; - } - else if (internal::is_same >::value) - { - mat.xtype = CHOLMOD_COMPLEX; - mat.dtype = CHOLMOD_DOUBLE; - } - else - { - imp_eigen_assert(false && "Scalar type not supported by CHOLMOD"); - } -} - -} // namespace internal - -/** Wraps the Eigen sparse matrix \a mat into a Cholmod sparse matrix object. - * Note that the data are shared. - */ -template -cholmod_sparse viewAsCholmod(SparseMatrix<_Scalar,_Options,_Index>& mat) -{ - cholmod_sparse res; - res.nzmax = mat.nonZeros(); - res.nrow = mat.rows();; - res.ncol = mat.cols(); - res.p = mat.outerIndexPtr(); - res.i = mat.innerIndexPtr(); - res.x = mat.valuePtr(); - res.z = 0; - res.sorted = 1; - if(mat.isCompressed()) - { - res.packed = 1; - res.nz = 0; - } - else - { - res.packed = 0; - res.nz = mat.innerNonZeroPtr(); - } - - res.dtype = 0; - res.stype = -1; - - if (internal::is_same<_Index,int>::value) - { - res.itype = CHOLMOD_INT; - } - else if (internal::is_same<_Index,SuiteSparse_long>::value) - { - res.itype = CHOLMOD_LONG; - } - else - { - imp_eigen_assert(false && "Index type not supported yet"); - } - - // setup res.xtype - internal::cholmod_configure_matrix<_Scalar>(res); - - res.stype = 0; - - return res; -} - -template -const cholmod_sparse viewAsCholmod(const SparseMatrix<_Scalar,_Options,_Index>& mat) -{ - cholmod_sparse res = viewAsCholmod(mat.const_cast_derived()); - return res; -} - -/** Returns a view of the Eigen sparse matrix \a mat as Cholmod sparse matrix. - * The data are not copied but shared. */ -template -cholmod_sparse viewAsCholmod(const SparseSelfAdjointView, UpLo>& mat) -{ - cholmod_sparse res = viewAsCholmod(mat.matrix().const_cast_derived()); - - if(UpLo==Upper) res.stype = 1; - if(UpLo==Lower) res.stype = -1; - - return res; -} - -/** Returns a view of the Eigen \b dense matrix \a mat as Cholmod dense matrix. - * The data are not copied but shared. */ -template -cholmod_dense viewAsCholmod(MatrixBase& mat) -{ - IMP_EIGEN_STATIC_ASSERT((internal::traits::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); - typedef typename Derived::Scalar Scalar; - - cholmod_dense res; - res.nrow = mat.rows(); - res.ncol = mat.cols(); - res.nzmax = res.nrow * res.ncol; - res.d = Derived::IsVectorAtCompileTime ? mat.derived().size() : mat.derived().outerStride(); - res.x = (void*)(mat.derived().data()); - res.z = 0; - - internal::cholmod_configure_matrix(res); - - return res; -} - -/** Returns a view of the Cholmod sparse matrix \a cm as an Eigen sparse matrix. - * The data are not copied but shared. */ -template -MappedSparseMatrix viewAsEigen(cholmod_sparse& cm) -{ - return MappedSparseMatrix - (cm.nrow, cm.ncol, static_cast(cm.p)[cm.ncol], - static_cast(cm.p), static_cast(cm.i),static_cast(cm.x) ); -} - -enum CholmodMode { - CholmodAuto, CholmodSimplicialLLt, CholmodSupernodalLLt, CholmodLDLt -}; - - -/** \ingroup CholmodSupport_Module - * \class CholmodBase - * \brief The base class for the direct Cholesky factorization of Cholmod - * \sa class CholmodSupernodalLLT, class CholmodSimplicialLDLT, class CholmodSimplicialLLT - */ -template -class CholmodBase : internal::noncopyable -{ - public: - typedef _MatrixType MatrixType; - enum { UpLo = _UpLo }; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; - typedef MatrixType CholMatrixType; - typedef typename MatrixType::Index Index; - - public: - - CholmodBase() - : m_cholmodFactor(0), m_info(Success), m_isInitialized(false) - { - m_shiftOffset[0] = m_shiftOffset[1] = RealScalar(0.0); - cholmod_start(&m_cholmod); - } - - CholmodBase(const MatrixType& matrix) - : m_cholmodFactor(0), m_info(Success), m_isInitialized(false) - { - m_shiftOffset[0] = m_shiftOffset[1] = RealScalar(0.0); - cholmod_start(&m_cholmod); - compute(matrix); - } - - ~CholmodBase() - { - if(m_cholmodFactor) - cholmod_free_factor(&m_cholmodFactor, &m_cholmod); - cholmod_finish(&m_cholmod); - } - - inline Index cols() const { return m_cholmodFactor->n; } - inline Index rows() const { return m_cholmodFactor->n; } - - Derived& derived() { return *static_cast(this); } - const Derived& derived() const { return *static_cast(this); } - - /** \brief Reports whether previous computation was successful. - * - * \returns \c Success if computation was succesful, - * \c NumericalIssue if the matrix.appears to be negative. - */ - ComputationInfo info() const - { - imp_eigen_assert(m_isInitialized && "Decomposition is not initialized."); - return m_info; - } - - /** Computes the sparse Cholesky decomposition of \a matrix */ - Derived& compute(const MatrixType& matrix) - { - analyzePattern(matrix); - factorize(matrix); - return derived(); - } - - /** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A. - * - * \sa compute() - */ - template - inline const internal::solve_retval - solve(const MatrixBase& b) const - { - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - imp_eigen_assert(rows()==b.rows() - && "CholmodDecomposition::solve(): invalid number of rows of the right hand side matrix b"); - return internal::solve_retval(*this, b.derived()); - } - - /** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A. - * - * \sa compute() - */ - template - inline const internal::sparse_solve_retval - solve(const SparseMatrixBase& b) const - { - imp_eigen_assert(m_isInitialized && "LLT is not initialized."); - imp_eigen_assert(rows()==b.rows() - && "CholmodDecomposition::solve(): invalid number of rows of the right hand side matrix b"); - return internal::sparse_solve_retval(*this, b.derived()); - } - - /** Performs a symbolic decomposition on the sparsity pattern of \a matrix. - * - * This function is particularly useful when solving for several problems having the same structure. - * - * \sa factorize() - */ - void analyzePattern(const MatrixType& matrix) - { - if(m_cholmodFactor) - { - cholmod_free_factor(&m_cholmodFactor, &m_cholmod); - m_cholmodFactor = 0; - } - cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView()); - m_cholmodFactor = cholmod_analyze(&A, &m_cholmod); - - this->m_isInitialized = true; - this->m_info = Success; - m_analysisIsOk = true; - m_factorizationIsOk = false; - } - - /** Performs a numeric decomposition of \a matrix - * - * The given matrix must have the same sparsity pattern as the matrix on which the symbolic decomposition has been performed. - * - * \sa analyzePattern() - */ - void factorize(const MatrixType& matrix) - { - imp_eigen_assert(m_analysisIsOk && "You must first call analyzePattern()"); - cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView()); - cholmod_factorize_p(&A, m_shiftOffset, 0, 0, m_cholmodFactor, &m_cholmod); - - // If the factorization failed, minor is the column at which it did. On success minor == n. - this->m_info = (m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue); - m_factorizationIsOk = true; - } - - /** Returns a reference to the Cholmod's configuration structure to get a full control over the performed operations. - * See the Cholmod user guide for details. */ - cholmod_common& cholmod() { return m_cholmod; } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** \internal */ - template - void _solve(const MatrixBase &b, MatrixBase &dest) const - { - imp_eigen_assert(m_factorizationIsOk && "The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()"); - const Index size = m_cholmodFactor->n; - IMP_EIGEN_UNUSED_VARIABLE(size); - imp_eigen_assert(size==b.rows()); - - // note: cd stands for Cholmod Dense - Rhs& b_ref(b.const_cast_derived()); - cholmod_dense b_cd = viewAsCholmod(b_ref); - cholmod_dense* x_cd = cholmod_solve(CHOLMOD_A, m_cholmodFactor, &b_cd, &m_cholmod); - if(!x_cd) - { - this->m_info = NumericalIssue; - } - // TODO optimize this copy by swapping when possible (be careful with alignment, etc.) - dest = Matrix::Map(reinterpret_cast(x_cd->x),b.rows(),b.cols()); - cholmod_free_dense(&x_cd, &m_cholmod); - } - - /** \internal */ - template - void _solve(const SparseMatrix &b, SparseMatrix &dest) const - { - imp_eigen_assert(m_factorizationIsOk && "The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()"); - const Index size = m_cholmodFactor->n; - IMP_EIGEN_UNUSED_VARIABLE(size); - imp_eigen_assert(size==b.rows()); - - // note: cs stands for Cholmod Sparse - cholmod_sparse b_cs = viewAsCholmod(b); - cholmod_sparse* x_cs = cholmod_spsolve(CHOLMOD_A, m_cholmodFactor, &b_cs, &m_cholmod); - if(!x_cs) - { - this->m_info = NumericalIssue; - } - // TODO optimize this copy by swapping when possible (be careful with alignment, etc.) - dest = viewAsEigen(*x_cs); - cholmod_free_sparse(&x_cs, &m_cholmod); - } - #endif // IMP_EIGEN_PARSED_BY_DOXYGEN - - - /** Sets the shift parameter that will be used to adjust the diagonal coefficients during the numerical factorization. - * - * During the numerical factorization, an offset term is added to the diagonal coefficients:\n - * \c d_ii = \a offset + \c d_ii - * - * The default is \a offset=0. - * - * \returns a reference to \c *this. - */ - Derived& setShift(const RealScalar& offset) - { - m_shiftOffset[0] = offset; - return derived(); - } - - template - void dumpMemory(Stream& /*s*/) - {} - - protected: - mutable cholmod_common m_cholmod; - cholmod_factor* m_cholmodFactor; - RealScalar m_shiftOffset[2]; - mutable ComputationInfo m_info; - bool m_isInitialized; - int m_factorizationIsOk; - int m_analysisIsOk; -}; - -/** \ingroup CholmodSupport_Module - * \class CholmodSimplicialLLT - * \brief A simplicial direct Cholesky (LLT) factorization and solver based on Cholmod - * - * This class allows to solve for A.X = B sparse linear problems via a simplicial LL^T Cholesky factorization - * using the Cholmod library. - * This simplicial variant is equivalent to Eigen's built-in SimplicialLLT class. Therefore, it has little practical interest. - * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices - * X and B can be either dense or sparse. - * - * \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<> - * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower - * or Upper. Default is Lower. - * - * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed. - * - * \sa \ref TutorialSparseDirectSolvers, class CholmodSupernodalLLT, class SimplicialLLT - */ -template -class CholmodSimplicialLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLLT<_MatrixType, _UpLo> > -{ - typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLLT> Base; - using Base::m_cholmod; - - public: - - typedef _MatrixType MatrixType; - - CholmodSimplicialLLT() : Base() { init(); } - - CholmodSimplicialLLT(const MatrixType& matrix) : Base() - { - init(); - Base::compute(matrix); - } - - ~CholmodSimplicialLLT() {} - protected: - void init() - { - m_cholmod.final_asis = 0; - m_cholmod.supernodal = CHOLMOD_SIMPLICIAL; - m_cholmod.final_ll = 1; - } -}; - - -/** \ingroup CholmodSupport_Module - * \class CholmodSimplicialLDLT - * \brief A simplicial direct Cholesky (LDLT) factorization and solver based on Cholmod - * - * This class allows to solve for A.X = B sparse linear problems via a simplicial LDL^T Cholesky factorization - * using the Cholmod library. - * This simplicial variant is equivalent to Eigen's built-in SimplicialLDLT class. Therefore, it has little practical interest. - * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices - * X and B can be either dense or sparse. - * - * \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<> - * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower - * or Upper. Default is Lower. - * - * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed. - * - * \sa \ref TutorialSparseDirectSolvers, class CholmodSupernodalLLT, class SimplicialLDLT - */ -template -class CholmodSimplicialLDLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLDLT<_MatrixType, _UpLo> > -{ - typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLDLT> Base; - using Base::m_cholmod; - - public: - - typedef _MatrixType MatrixType; - - CholmodSimplicialLDLT() : Base() { init(); } - - CholmodSimplicialLDLT(const MatrixType& matrix) : Base() - { - init(); - Base::compute(matrix); - } - - ~CholmodSimplicialLDLT() {} - protected: - void init() - { - m_cholmod.final_asis = 1; - m_cholmod.supernodal = CHOLMOD_SIMPLICIAL; - } -}; - -/** \ingroup CholmodSupport_Module - * \class CholmodSupernodalLLT - * \brief A supernodal Cholesky (LLT) factorization and solver based on Cholmod - * - * This class allows to solve for A.X = B sparse linear problems via a supernodal LL^T Cholesky factorization - * using the Cholmod library. - * This supernodal variant performs best on dense enough problems, e.g., 3D FEM, or very high order 2D FEM. - * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices - * X and B can be either dense or sparse. - * - * \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<> - * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower - * or Upper. Default is Lower. - * - * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed. - * - * \sa \ref TutorialSparseDirectSolvers - */ -template -class CholmodSupernodalLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSupernodalLLT<_MatrixType, _UpLo> > -{ - typedef CholmodBase<_MatrixType, _UpLo, CholmodSupernodalLLT> Base; - using Base::m_cholmod; - - public: - - typedef _MatrixType MatrixType; - - CholmodSupernodalLLT() : Base() { init(); } - - CholmodSupernodalLLT(const MatrixType& matrix) : Base() - { - init(); - Base::compute(matrix); - } - - ~CholmodSupernodalLLT() {} - protected: - void init() - { - m_cholmod.final_asis = 1; - m_cholmod.supernodal = CHOLMOD_SUPERNODAL; - } -}; - -/** \ingroup CholmodSupport_Module - * \class CholmodDecomposition - * \brief A general Cholesky factorization and solver based on Cholmod - * - * This class allows to solve for A.X = B sparse linear problems via a LL^T or LDL^T Cholesky factorization - * using the Cholmod library. The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices - * X and B can be either dense or sparse. - * - * This variant permits to change the underlying Cholesky method at runtime. - * On the other hand, it does not provide access to the result of the factorization. - * The default is to let Cholmod automatically choose between a simplicial and supernodal factorization. - * - * \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<> - * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower - * or Upper. Default is Lower. - * - * This class supports all kind of SparseMatrix<>: row or column major; upper, lower, or both; compressed or non compressed. - * - * \sa \ref TutorialSparseDirectSolvers - */ -template -class CholmodDecomposition : public CholmodBase<_MatrixType, _UpLo, CholmodDecomposition<_MatrixType, _UpLo> > -{ - typedef CholmodBase<_MatrixType, _UpLo, CholmodDecomposition> Base; - using Base::m_cholmod; - - public: - - typedef _MatrixType MatrixType; - - CholmodDecomposition() : Base() { init(); } - - CholmodDecomposition(const MatrixType& matrix) : Base() - { - init(); - Base::compute(matrix); - } - - ~CholmodDecomposition() {} - - void setMode(CholmodMode mode) - { - switch(mode) - { - case CholmodAuto: - m_cholmod.final_asis = 1; - m_cholmod.supernodal = CHOLMOD_AUTO; - break; - case CholmodSimplicialLLt: - m_cholmod.final_asis = 0; - m_cholmod.supernodal = CHOLMOD_SIMPLICIAL; - m_cholmod.final_ll = 1; - break; - case CholmodSupernodalLLt: - m_cholmod.final_asis = 1; - m_cholmod.supernodal = CHOLMOD_SUPERNODAL; - break; - case CholmodLDLt: - m_cholmod.final_asis = 1; - m_cholmod.supernodal = CHOLMOD_SIMPLICIAL; - break; - default: - break; - } - } - protected: - void init() - { - m_cholmod.final_asis = 1; - m_cholmod.supernodal = CHOLMOD_AUTO; - } -}; - -namespace internal { - -template -struct solve_retval, Rhs> - : solve_retval_base, Rhs> -{ - typedef CholmodBase<_MatrixType,_UpLo,Derived> Dec; - IMP_EIGEN_MAKE_SOLVE_HELPERS(Dec,Rhs) - - template void evalTo(Dest& dst) const - { - dec()._solve(rhs(),dst); - } -}; - -template -struct sparse_solve_retval, Rhs> - : sparse_solve_retval_base, Rhs> -{ - typedef CholmodBase<_MatrixType,_UpLo,Derived> Dec; - IMP_EIGEN_MAKE_SPARSE_SOLVE_HELPERS(Dec,Rhs) - - template void evalTo(Dest& dst) const - { - dec()._solve(rhs(),dst); - } -}; - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_CHOLMODSUPPORT_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Array.h b/modules/algebra/include/eigen3/Eigen/src/Core/Array.h deleted file mode 100644 index 66be197bd4..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Array.h +++ /dev/null @@ -1,323 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_ARRAY_H -#define IMP_EIGEN_ARRAY_H - -namespace IMP_Eigen { - -/** \class Array - * \ingroup Core_Module - * - * \brief General-purpose arrays with easy API for coefficient-wise operations - * - * The %Array class is very similar to the Matrix class. It provides - * general-purpose one- and two-dimensional arrays. The difference between the - * %Array and the %Matrix class is primarily in the API: the API for the - * %Array class provides easy access to coefficient-wise operations, while the - * API for the %Matrix class provides easy access to linear-algebra - * operations. - * - * This class can be extended with the help of the plugin mechanism described on the page - * \ref TopicCustomizingEigen by defining the preprocessor symbol \c IMP_EIGEN_ARRAY_PLUGIN. - * - * \sa \ref TutorialArrayClass, \ref TopicClassHierarchy - */ -namespace internal { -template -struct traits > : traits > -{ - typedef ArrayXpr XprKind; - typedef ArrayBase > XprBase; -}; -} - -template -class Array - : public PlainObjectBase > -{ - public: - - typedef PlainObjectBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Array) - - enum { Options = _Options }; - typedef typename Base::PlainObject PlainObject; - - protected: - template - friend struct internal::conservative_resize_like_impl; - - using Base::m_storage; - - public: - - using Base::base; - using Base::coeff; - using Base::coeffRef; - - /** - * The usage of - * using Base::operator=; - * fails on MSVC. Since the code below is working with GCC and MSVC, we skipped - * the usage of 'using'. This should be done only for operator=. - */ - template - IMP_EIGEN_STRONG_INLINE Array& operator=(const EigenBase &other) - { - return Base::operator=(other); - } - - /** Copies the value of the expression \a other into \c *this with automatic resizing. - * - * *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized), - * it will be initialized. - * - * Note that copying a row-vector into a vector (and conversely) is allowed. - * The resizing, if any, is then done in the appropriate way so that row-vectors - * remain row-vectors and vectors remain vectors. - */ - template - IMP_EIGEN_STRONG_INLINE Array& operator=(const ArrayBase& other) - { - return Base::_set(other); - } - - /** This is a special case of the templated operator=. Its purpose is to - * prevent a default operator= from hiding the templated operator=. - */ - IMP_EIGEN_STRONG_INLINE Array& operator=(const Array& other) - { - return Base::_set(other); - } - - /** Default constructor. - * - * For fixed-size matrices, does nothing. - * - * For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix - * is called a null matrix. This constructor is the unique way to create null matrices: resizing - * a matrix to 0 is not supported. - * - * \sa resize(Index,Index) - */ - IMP_EIGEN_STRONG_INLINE Array() : Base() - { - Base::_check_template_params(); - IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - // FIXME is it still needed ?? - /** \internal */ - Array(internal::constructor_without_unaligned_array_assert) - : Base(internal::constructor_without_unaligned_array_assert()) - { - Base::_check_template_params(); - IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } -#endif - -#ifdef IMP_EIGEN_HAVE_RVALUE_REFERENCES - Array(Array&& other) - : Base(std::move(other)) - { - Base::_check_template_params(); - if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic) - Base::_set_noalias(other); - } - Array& operator=(Array&& other) - { - other.swap(*this); - return *this; - } -#endif - - /** Constructs a vector or row-vector with given dimension. \only_for_vectors - * - * Note that this is only useful for dynamic-size vectors. For fixed-size vectors, - * it is redundant to pass the dimension here, so it makes more sense to use the default - * constructor Matrix() instead. - */ - IMP_EIGEN_STRONG_INLINE explicit Array(Index dim) - : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim) - { - Base::_check_template_params(); - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array) - imp_eigen_assert(dim >= 0); - imp_eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); - IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - template - IMP_EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1) - { - Base::_check_template_params(); - this->template _init2(val0, val1); - } - #else - /** constructs an uninitialized matrix with \a rows rows and \a cols columns. - * - * This is useful for dynamic-size matrices. For fixed-size matrices, - * it is redundant to pass these parameters, so one should use the default constructor - * Matrix() instead. */ - Array(Index rows, Index cols); - /** constructs an initialized 2D vector with given coefficients */ - Array(const Scalar& val0, const Scalar& val1); - #endif - - /** constructs an initialized 3D vector with given coefficients */ - IMP_EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2) - { - Base::_check_template_params(); - IMP_EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3) - m_storage.data()[0] = val0; - m_storage.data()[1] = val1; - m_storage.data()[2] = val2; - } - /** constructs an initialized 4D vector with given coefficients */ - IMP_EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2, const Scalar& val3) - { - Base::_check_template_params(); - IMP_EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4) - m_storage.data()[0] = val0; - m_storage.data()[1] = val1; - m_storage.data()[2] = val2; - m_storage.data()[3] = val3; - } - - explicit Array(const Scalar *data); - - /** Constructor copying the value of the expression \a other */ - template - IMP_EIGEN_STRONG_INLINE Array(const ArrayBase& other) - : Base(other.rows() * other.cols(), other.rows(), other.cols()) - { - Base::_check_template_params(); - Base::_set_noalias(other); - } - /** Copy constructor */ - IMP_EIGEN_STRONG_INLINE Array(const Array& other) - : Base(other.rows() * other.cols(), other.rows(), other.cols()) - { - Base::_check_template_params(); - Base::_set_noalias(other); - } - /** Copy constructor with in-place evaluation */ - template - IMP_EIGEN_STRONG_INLINE Array(const ReturnByValue& other) - { - Base::_check_template_params(); - Base::resize(other.rows(), other.cols()); - other.evalTo(*this); - } - - /** \sa MatrixBase::operator=(const EigenBase&) */ - template - IMP_EIGEN_STRONG_INLINE Array(const EigenBase &other) - : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols()) - { - Base::_check_template_params(); - Base::_resize_to_match(other); - *this = other; - } - - /** Override MatrixBase::swap() since for dynamic-sized matrices of same type it is enough to swap the - * data pointers. - */ - template - void swap(ArrayBase const & other) - { this->_swap(other.derived()); } - - inline Index innerStride() const { return 1; } - inline Index outerStride() const { return this->innerSize(); } - - #ifdef IMP_EIGEN_ARRAY_PLUGIN - #include IMP_EIGEN_ARRAY_PLUGIN - #endif - - private: - - template - friend struct internal::matrix_swap_impl; -}; - -/** \defgroup arraytypedefs Global array typedefs - * \ingroup Core_Module - * - * Eigen defines several typedef shortcuts for most common 1D and 2D array types. - * - * The general patterns are the following: - * - * \c ArrayRowsColsType where \c Rows and \c Cols can be \c 2,\c 3,\c 4 for fixed size square matrices or \c X for dynamic size, - * and where \c Type can be \c i for integer, \c f for float, \c d for double, \c cf for complex float, \c cd - * for complex double. - * - * For example, \c Array33d is a fixed-size 3x3 array type of doubles, and \c ArrayXXf is a dynamic-size matrix of floats. - * - * There are also \c ArraySizeType which are self-explanatory. For example, \c Array4cf is - * a fixed-size 1D array of 4 complex floats. - * - * \sa class Array - */ - -#define IMP_EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ -/** \ingroup arraytypedefs */ \ -typedef Array Array##SizeSuffix##SizeSuffix##TypeSuffix; \ -/** \ingroup arraytypedefs */ \ -typedef Array Array##SizeSuffix##TypeSuffix; - -#define IMP_EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \ -/** \ingroup arraytypedefs */ \ -typedef Array Array##Size##X##TypeSuffix; \ -/** \ingroup arraytypedefs */ \ -typedef Array Array##X##Size##TypeSuffix; - -#define IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \ -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \ -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \ -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \ -IMP_EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \ -IMP_EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \ -IMP_EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4) - -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int, i) -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float, f) -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double, d) -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex, cf) -IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex, cd) - -#undef IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES -#undef IMP_EIGEN_MAKE_ARRAY_TYPEDEFS - -#undef IMP_EIGEN_MAKE_ARRAY_TYPEDEFS_LARGE - -#define IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \ -using IMP_Eigen::Matrix##SizeSuffix##TypeSuffix; \ -using IMP_Eigen::Vector##SizeSuffix##TypeSuffix; \ -using IMP_Eigen::RowVector##SizeSuffix##TypeSuffix; - -#define IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \ - -#define IMP_EIGEN_USING_ARRAY_TYPEDEFS \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \ -IMP_EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd) - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_ARRAY_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/ArrayBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/ArrayBase.h deleted file mode 100644 index e06009d26d..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/ArrayBase.h +++ /dev/null @@ -1,226 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_ARRAYBASE_H -#define IMP_EIGEN_ARRAYBASE_H - -namespace IMP_Eigen { - -template class MatrixWrapper; - -/** \class ArrayBase - * \ingroup Core_Module - * - * \brief Base class for all 1D and 2D array, and related expressions - * - * An array is similar to a dense vector or matrix. While matrices are mathematical - * objects with well defined linear algebra operators, an array is just a collection - * of scalar values arranged in a one or two dimensionnal fashion. As the main consequence, - * all operations applied to an array are performed coefficient wise. Furthermore, - * arrays support scalar math functions of the c++ standard library (e.g., std::sin(x)), and convenient - * constructors allowing to easily write generic code working for both scalar values - * and arrays. - * - * This class is the base that is inherited by all array expression types. - * - * \tparam Derived is the derived type, e.g., an array or an expression type. - * - * This class can be extended with the help of the plugin mechanism described on the page - * \ref TopicCustomizingEigen by defining the preprocessor symbol \c IMP_EIGEN_ARRAYBASE_PLUGIN. - * - * \sa class MatrixBase, \ref TopicClassHierarchy - */ -template class ArrayBase - : public DenseBase -{ - public: -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** The base class for a given storage type. */ - typedef ArrayBase StorageBaseType; - - typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl; - - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::packet_traits::type PacketScalar; - typedef typename NumTraits::Real RealScalar; - - typedef DenseBase Base; - using Base::operator*; - using Base::RowsAtCompileTime; - using Base::ColsAtCompileTime; - using Base::SizeAtCompileTime; - using Base::MaxRowsAtCompileTime; - using Base::MaxColsAtCompileTime; - using Base::MaxSizeAtCompileTime; - using Base::IsVectorAtCompileTime; - using Base::Flags; - using Base::CoeffReadCost; - - using Base::derived; - using Base::const_cast_derived; - using Base::rows; - using Base::cols; - using Base::size; - using Base::coeff; - using Base::coeffRef; - using Base::lazyAssign; - using Base::operator=; - using Base::operator+=; - using Base::operator-=; - using Base::operator*=; - using Base::operator/=; - - typedef typename Base::CoeffReturnType CoeffReturnType; - -#endif // not IMP_EIGEN_PARSED_BY_DOXYGEN - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** \internal the plain matrix type corresponding to this expression. Note that is not necessarily - * exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const - * reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either - * PlainObject or const PlainObject&. - */ - typedef Array::Scalar, - internal::traits::RowsAtCompileTime, - internal::traits::ColsAtCompileTime, - AutoAlign | (internal::traits::Flags&RowMajorBit ? RowMajor : ColMajor), - internal::traits::MaxRowsAtCompileTime, - internal::traits::MaxColsAtCompileTime - > PlainObject; - - - /** \internal Represents a matrix with all coefficients equal to one another*/ - typedef CwiseNullaryOp,Derived> ConstantReturnType; -#endif // not IMP_EIGEN_PARSED_BY_DOXYGEN - -#define IMP_EIGEN_CURRENT_STORAGE_BASE_CLASS IMP_Eigen::ArrayBase -# include "../plugins/CommonCwiseUnaryOps.h" -# include "../plugins/MatrixCwiseUnaryOps.h" -# include "../plugins/ArrayCwiseUnaryOps.h" -# include "../plugins/CommonCwiseBinaryOps.h" -# include "../plugins/MatrixCwiseBinaryOps.h" -# include "../plugins/ArrayCwiseBinaryOps.h" -# ifdef IMP_EIGEN_ARRAYBASE_PLUGIN -# include IMP_EIGEN_ARRAYBASE_PLUGIN -# endif -#undef IMP_EIGEN_CURRENT_STORAGE_BASE_CLASS - - /** Special case of the template operator=, in order to prevent the compiler - * from generating a default operator= (issue hit with g++ 4.1) - */ - Derived& operator=(const ArrayBase& other) - { - return internal::assign_selector::run(derived(), other.derived()); - } - - Derived& operator+=(const Scalar& scalar) - { return *this = derived() + scalar; } - Derived& operator-=(const Scalar& scalar) - { return *this = derived() - scalar; } - - template - Derived& operator+=(const ArrayBase& other); - template - Derived& operator-=(const ArrayBase& other); - - template - Derived& operator*=(const ArrayBase& other); - - template - Derived& operator/=(const ArrayBase& other); - - public: - ArrayBase& array() { return *this; } - const ArrayBase& array() const { return *this; } - - /** \returns an \link IMP_Eigen::MatrixBase Matrix \endlink expression of this array - * \sa MatrixBase::array() */ - MatrixWrapper matrix() { return derived(); } - const MatrixWrapper matrix() const { return derived(); } - -// template -// inline void evalTo(Dest& dst) const { dst = matrix(); } - - protected: - ArrayBase() : Base() {} - - private: - explicit ArrayBase(Index); - ArrayBase(Index,Index); - template explicit ArrayBase(const ArrayBase&); - protected: - // mixing arrays and matrices is not legal - template Derived& operator+=(const MatrixBase& ) - {IMP_EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;} - // mixing arrays and matrices is not legal - template Derived& operator-=(const MatrixBase& ) - {IMP_EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;} -}; - -/** replaces \c *this by \c *this - \a other. - * - * \returns a reference to \c *this - */ -template -template -IMP_EIGEN_STRONG_INLINE Derived & -ArrayBase::operator-=(const ArrayBase &other) -{ - SelfCwiseBinaryOp, Derived, OtherDerived> tmp(derived()); - tmp = other.derived(); - return derived(); -} - -/** replaces \c *this by \c *this + \a other. - * - * \returns a reference to \c *this - */ -template -template -IMP_EIGEN_STRONG_INLINE Derived & -ArrayBase::operator+=(const ArrayBase& other) -{ - SelfCwiseBinaryOp, Derived, OtherDerived> tmp(derived()); - tmp = other.derived(); - return derived(); -} - -/** replaces \c *this by \c *this * \a other coefficient wise. - * - * \returns a reference to \c *this - */ -template -template -IMP_EIGEN_STRONG_INLINE Derived & -ArrayBase::operator*=(const ArrayBase& other) -{ - SelfCwiseBinaryOp, Derived, OtherDerived> tmp(derived()); - tmp = other.derived(); - return derived(); -} - -/** replaces \c *this by \c *this / \a other coefficient wise. - * - * \returns a reference to \c *this - */ -template -template -IMP_EIGEN_STRONG_INLINE Derived & -ArrayBase::operator/=(const ArrayBase& other) -{ - SelfCwiseBinaryOp, Derived, OtherDerived> tmp(derived()); - tmp = other.derived(); - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_ARRAYBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/ArrayWrapper.h b/modules/algebra/include/eigen3/Eigen/src/Core/ArrayWrapper.h deleted file mode 100644 index bb5f92a641..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/ArrayWrapper.h +++ /dev/null @@ -1,264 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_ARRAYWRAPPER_H -#define IMP_EIGEN_ARRAYWRAPPER_H - -namespace IMP_Eigen { - -/** \class ArrayWrapper - * \ingroup Core_Module - * - * \brief Expression of a mathematical vector or matrix as an array object - * - * This class is the return type of MatrixBase::array(), and most of the time - * this is the only way it is use. - * - * \sa MatrixBase::array(), class MatrixWrapper - */ - -namespace internal { -template -struct traits > - : public traits::type > -{ - typedef ArrayXpr XprKind; - // Let's remove NestByRefBit - enum { - Flags0 = traits::type >::Flags, - Flags = Flags0 & ~NestByRefBit - }; -}; -} - -template -class ArrayWrapper : public ArrayBase > -{ - public: - typedef ArrayBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper) - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper) - - typedef typename internal::conditional< - internal::is_lvalue::value, - Scalar, - const Scalar - >::type ScalarWithConstIfNotLvalue; - - typedef typename internal::nested::type NestedExpressionType; - - inline ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {} - - inline Index rows() const { return m_expression.rows(); } - inline Index cols() const { return m_expression.cols(); } - inline Index outerStride() const { return m_expression.outerStride(); } - inline Index innerStride() const { return m_expression.innerStride(); } - - inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); } - inline const Scalar* data() const { return m_expression.data(); } - - inline CoeffReturnType coeff(Index rowId, Index colId) const - { - return m_expression.coeff(rowId, colId); - } - - inline Scalar& coeffRef(Index rowId, Index colId) - { - return m_expression.const_cast_derived().coeffRef(rowId, colId); - } - - inline const Scalar& coeffRef(Index rowId, Index colId) const - { - return m_expression.const_cast_derived().coeffRef(rowId, colId); - } - - inline CoeffReturnType coeff(Index index) const - { - return m_expression.coeff(index); - } - - inline Scalar& coeffRef(Index index) - { - return m_expression.const_cast_derived().coeffRef(index); - } - - inline const Scalar& coeffRef(Index index) const - { - return m_expression.const_cast_derived().coeffRef(index); - } - - template - inline const PacketScalar packet(Index rowId, Index colId) const - { - return m_expression.template packet(rowId, colId); - } - - template - inline void writePacket(Index rowId, Index colId, const PacketScalar& val) - { - m_expression.const_cast_derived().template writePacket(rowId, colId, val); - } - - template - inline const PacketScalar packet(Index index) const - { - return m_expression.template packet(index); - } - - template - inline void writePacket(Index index, const PacketScalar& val) - { - m_expression.const_cast_derived().template writePacket(index, val); - } - - template - inline void evalTo(Dest& dst) const { dst = m_expression; } - - const typename internal::remove_all::type& - nestedExpression() const - { - return m_expression; - } - - /** Forwards the resizing request to the nested expression - * \sa DenseBase::resize(Index) */ - void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); } - /** Forwards the resizing request to the nested expression - * \sa DenseBase::resize(Index,Index)*/ - void resize(Index nbRows, Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); } - - protected: - NestedExpressionType m_expression; -}; - -/** \class MatrixWrapper - * \ingroup Core_Module - * - * \brief Expression of an array as a mathematical vector or matrix - * - * This class is the return type of ArrayBase::matrix(), and most of the time - * this is the only way it is use. - * - * \sa MatrixBase::matrix(), class ArrayWrapper - */ - -namespace internal { -template -struct traits > - : public traits::type > -{ - typedef MatrixXpr XprKind; - // Let's remove NestByRefBit - enum { - Flags0 = traits::type >::Flags, - Flags = Flags0 & ~NestByRefBit - }; -}; -} - -template -class MatrixWrapper : public MatrixBase > -{ - public: - typedef MatrixBase > Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper) - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper) - - typedef typename internal::conditional< - internal::is_lvalue::value, - Scalar, - const Scalar - >::type ScalarWithConstIfNotLvalue; - - typedef typename internal::nested::type NestedExpressionType; - - inline MatrixWrapper(ExpressionType& a_matrix) : m_expression(a_matrix) {} - - inline Index rows() const { return m_expression.rows(); } - inline Index cols() const { return m_expression.cols(); } - inline Index outerStride() const { return m_expression.outerStride(); } - inline Index innerStride() const { return m_expression.innerStride(); } - - inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); } - inline const Scalar* data() const { return m_expression.data(); } - - inline CoeffReturnType coeff(Index rowId, Index colId) const - { - return m_expression.coeff(rowId, colId); - } - - inline Scalar& coeffRef(Index rowId, Index colId) - { - return m_expression.const_cast_derived().coeffRef(rowId, colId); - } - - inline const Scalar& coeffRef(Index rowId, Index colId) const - { - return m_expression.derived().coeffRef(rowId, colId); - } - - inline CoeffReturnType coeff(Index index) const - { - return m_expression.coeff(index); - } - - inline Scalar& coeffRef(Index index) - { - return m_expression.const_cast_derived().coeffRef(index); - } - - inline const Scalar& coeffRef(Index index) const - { - return m_expression.const_cast_derived().coeffRef(index); - } - - template - inline const PacketScalar packet(Index rowId, Index colId) const - { - return m_expression.template packet(rowId, colId); - } - - template - inline void writePacket(Index rowId, Index colId, const PacketScalar& val) - { - m_expression.const_cast_derived().template writePacket(rowId, colId, val); - } - - template - inline const PacketScalar packet(Index index) const - { - return m_expression.template packet(index); - } - - template - inline void writePacket(Index index, const PacketScalar& val) - { - m_expression.const_cast_derived().template writePacket(index, val); - } - - const typename internal::remove_all::type& - nestedExpression() const - { - return m_expression; - } - - /** Forwards the resizing request to the nested expression - * \sa DenseBase::resize(Index) */ - void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); } - /** Forwards the resizing request to the nested expression - * \sa DenseBase::resize(Index,Index)*/ - void resize(Index nbRows, Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); } - - protected: - NestedExpressionType m_expression; -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_ARRAYWRAPPER_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Assign.h b/modules/algebra/include/eigen3/Eigen/src/Core/Assign.h deleted file mode 100644 index b6b6663be1..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Assign.h +++ /dev/null @@ -1,590 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2007 Michael Olbrich -// Copyright (C) 2006-2010 Benoit Jacob -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_ASSIGN_H -#define IMP_EIGEN_ASSIGN_H - -namespace IMP_Eigen { - -namespace internal { - -/*************************************************************************** -* Part 1 : the logic deciding a strategy for traversal and unrolling * -***************************************************************************/ - -template -struct assign_traits -{ -public: - enum { - DstIsAligned = Derived::Flags & AlignedBit, - DstHasDirectAccess = Derived::Flags & DirectAccessBit, - SrcIsAligned = OtherDerived::Flags & AlignedBit, - JointAlignment = bool(DstIsAligned) && bool(SrcIsAligned) ? Aligned : Unaligned - }; - -private: - enum { - InnerSize = int(Derived::IsVectorAtCompileTime) ? int(Derived::SizeAtCompileTime) - : int(Derived::Flags)&RowMajorBit ? int(Derived::ColsAtCompileTime) - : int(Derived::RowsAtCompileTime), - InnerMaxSize = int(Derived::IsVectorAtCompileTime) ? int(Derived::MaxSizeAtCompileTime) - : int(Derived::Flags)&RowMajorBit ? int(Derived::MaxColsAtCompileTime) - : int(Derived::MaxRowsAtCompileTime), - MaxSizeAtCompileTime = Derived::SizeAtCompileTime, - PacketSize = packet_traits::size - }; - - enum { - StorageOrdersAgree = (int(Derived::IsRowMajor) == int(OtherDerived::IsRowMajor)), - MightVectorize = StorageOrdersAgree - && (int(Derived::Flags) & int(OtherDerived::Flags) & ActualPacketAccessBit), - MayInnerVectorize = MightVectorize && int(InnerSize)!=Dynamic && int(InnerSize)%int(PacketSize)==0 - && int(DstIsAligned) && int(SrcIsAligned), - MayLinearize = StorageOrdersAgree && (int(Derived::Flags) & int(OtherDerived::Flags) & LinearAccessBit), - MayLinearVectorize = MightVectorize && MayLinearize && DstHasDirectAccess - && (DstIsAligned || MaxSizeAtCompileTime == Dynamic), - /* If the destination isn't aligned, we have to do runtime checks and we don't unroll, - so it's only good for large enough sizes. */ - MaySliceVectorize = MightVectorize && DstHasDirectAccess - && (int(InnerMaxSize)==Dynamic || int(InnerMaxSize)>=3*PacketSize) - /* slice vectorization can be slow, so we only want it if the slices are big, which is - indicated by InnerMaxSize rather than InnerSize, think of the case of a dynamic block - in a fixed-size matrix */ - }; - -public: - enum { - Traversal = int(MayInnerVectorize) ? int(InnerVectorizedTraversal) - : int(MayLinearVectorize) ? int(LinearVectorizedTraversal) - : int(MaySliceVectorize) ? int(SliceVectorizedTraversal) - : int(MayLinearize) ? int(LinearTraversal) - : int(DefaultTraversal), - Vectorized = int(Traversal) == InnerVectorizedTraversal - || int(Traversal) == LinearVectorizedTraversal - || int(Traversal) == SliceVectorizedTraversal - }; - -private: - enum { - UnrollingLimit = IMP_EIGEN_UNROLLING_LIMIT * (Vectorized ? int(PacketSize) : 1), - MayUnrollCompletely = int(Derived::SizeAtCompileTime) != Dynamic - && int(OtherDerived::CoeffReadCost) != Dynamic - && int(Derived::SizeAtCompileTime) * int(OtherDerived::CoeffReadCost) <= int(UnrollingLimit), - MayUnrollInner = int(InnerSize) != Dynamic - && int(OtherDerived::CoeffReadCost) != Dynamic - && int(InnerSize) * int(OtherDerived::CoeffReadCost) <= int(UnrollingLimit) - }; - -public: - enum { - Unrolling = (int(Traversal) == int(InnerVectorizedTraversal) || int(Traversal) == int(DefaultTraversal)) - ? ( - int(MayUnrollCompletely) ? int(CompleteUnrolling) - : int(MayUnrollInner) ? int(InnerUnrolling) - : int(NoUnrolling) - ) - : int(Traversal) == int(LinearVectorizedTraversal) - ? ( bool(MayUnrollCompletely) && bool(DstIsAligned) ? int(CompleteUnrolling) : int(NoUnrolling) ) - : int(Traversal) == int(LinearTraversal) - ? ( bool(MayUnrollCompletely) ? int(CompleteUnrolling) : int(NoUnrolling) ) - : int(NoUnrolling) - }; - -#ifdef IMP_EIGEN_DEBUG_ASSIGN - static void debug() - { - IMP_EIGEN_DEBUG_VAR(DstIsAligned) - IMP_EIGEN_DEBUG_VAR(SrcIsAligned) - IMP_EIGEN_DEBUG_VAR(JointAlignment) - IMP_EIGEN_DEBUG_VAR(InnerSize) - IMP_EIGEN_DEBUG_VAR(InnerMaxSize) - IMP_EIGEN_DEBUG_VAR(PacketSize) - IMP_EIGEN_DEBUG_VAR(StorageOrdersAgree) - IMP_EIGEN_DEBUG_VAR(MightVectorize) - IMP_EIGEN_DEBUG_VAR(MayLinearize) - IMP_EIGEN_DEBUG_VAR(MayInnerVectorize) - IMP_EIGEN_DEBUG_VAR(MayLinearVectorize) - IMP_EIGEN_DEBUG_VAR(MaySliceVectorize) - IMP_EIGEN_DEBUG_VAR(Traversal) - IMP_EIGEN_DEBUG_VAR(UnrollingLimit) - IMP_EIGEN_DEBUG_VAR(MayUnrollCompletely) - IMP_EIGEN_DEBUG_VAR(MayUnrollInner) - IMP_EIGEN_DEBUG_VAR(Unrolling) - } -#endif -}; - -/*************************************************************************** -* Part 2 : meta-unrollers -***************************************************************************/ - -/************************ -*** Default traversal *** -************************/ - -template -struct assign_DefaultTraversal_CompleteUnrolling -{ - enum { - outer = Index / Derived1::InnerSizeAtCompileTime, - inner = Index % Derived1::InnerSizeAtCompileTime - }; - - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - dst.copyCoeffByOuterInner(outer, inner, src); - assign_DefaultTraversal_CompleteUnrolling::run(dst, src); - } -}; - -template -struct assign_DefaultTraversal_CompleteUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &) {} -}; - -template -struct assign_DefaultTraversal_InnerUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src, typename Derived1::Index outer) - { - dst.copyCoeffByOuterInner(outer, Index, src); - assign_DefaultTraversal_InnerUnrolling::run(dst, src, outer); - } -}; - -template -struct assign_DefaultTraversal_InnerUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &, typename Derived1::Index) {} -}; - -/*********************** -*** Linear traversal *** -***********************/ - -template -struct assign_LinearTraversal_CompleteUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - dst.copyCoeff(Index, src); - assign_LinearTraversal_CompleteUnrolling::run(dst, src); - } -}; - -template -struct assign_LinearTraversal_CompleteUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &) {} -}; - -/************************** -*** Inner vectorization *** -**************************/ - -template -struct assign_innervec_CompleteUnrolling -{ - enum { - outer = Index / Derived1::InnerSizeAtCompileTime, - inner = Index % Derived1::InnerSizeAtCompileTime, - JointAlignment = assign_traits::JointAlignment - }; - - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - dst.template copyPacketByOuterInner(outer, inner, src); - assign_innervec_CompleteUnrolling::size, Stop>::run(dst, src); - } -}; - -template -struct assign_innervec_CompleteUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &) {} -}; - -template -struct assign_innervec_InnerUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src, typename Derived1::Index outer) - { - dst.template copyPacketByOuterInner(outer, Index, src); - assign_innervec_InnerUnrolling::size, Stop>::run(dst, src, outer); - } -}; - -template -struct assign_innervec_InnerUnrolling -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &, const Derived2 &, typename Derived1::Index) {} -}; - -/*************************************************************************** -* Part 3 : implementation of all cases -***************************************************************************/ - -template::Traversal, - int Unrolling = assign_traits::Unrolling, - int Version = Specialized> -struct assign_impl; - -/************************ -*** Default traversal *** -************************/ - -template -struct assign_impl -{ - static inline void run(Derived1 &, const Derived2 &) { } -}; - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static inline void run(Derived1 &dst, const Derived2 &src) - { - const Index innerSize = dst.innerSize(); - const Index outerSize = dst.outerSize(); - for(Index outer = 0; outer < outerSize; ++outer) - for(Index inner = 0; inner < innerSize; ++inner) - dst.copyCoeffByOuterInner(outer, inner, src); - } -}; - -template -struct assign_impl -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - assign_DefaultTraversal_CompleteUnrolling - ::run(dst, src); - } -}; - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - const Index outerSize = dst.outerSize(); - for(Index outer = 0; outer < outerSize; ++outer) - assign_DefaultTraversal_InnerUnrolling - ::run(dst, src, outer); - } -}; - -/*********************** -*** Linear traversal *** -***********************/ - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static inline void run(Derived1 &dst, const Derived2 &src) - { - const Index size = dst.size(); - for(Index i = 0; i < size; ++i) - dst.copyCoeff(i, src); - } -}; - -template -struct assign_impl -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - assign_LinearTraversal_CompleteUnrolling - ::run(dst, src); - } -}; - -/************************** -*** Inner vectorization *** -**************************/ - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static inline void run(Derived1 &dst, const Derived2 &src) - { - const Index innerSize = dst.innerSize(); - const Index outerSize = dst.outerSize(); - const Index packetSize = packet_traits::size; - for(Index outer = 0; outer < outerSize; ++outer) - for(Index inner = 0; inner < innerSize; inner+=packetSize) - dst.template copyPacketByOuterInner(outer, inner, src); - } -}; - -template -struct assign_impl -{ - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - assign_innervec_CompleteUnrolling - ::run(dst, src); - } -}; - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - const Index outerSize = dst.outerSize(); - for(Index outer = 0; outer < outerSize; ++outer) - assign_innervec_InnerUnrolling - ::run(dst, src, outer); - } -}; - -/*************************** -*** Linear vectorization *** -***************************/ - -template -struct unaligned_assign_impl -{ - template - static IMP_EIGEN_STRONG_INLINE void run(const Derived&, OtherDerived&, typename Derived::Index, typename Derived::Index) {} -}; - -template <> -struct unaligned_assign_impl -{ - // MSVC must not inline this functions. If it does, it fails to optimize the - // packet access path. -#ifdef _MSC_VER - template - static IMP_EIGEN_DONT_INLINE void run(const Derived& src, OtherDerived& dst, typename Derived::Index start, typename Derived::Index end) -#else - template - static IMP_EIGEN_STRONG_INLINE void run(const Derived& src, OtherDerived& dst, typename Derived::Index start, typename Derived::Index end) -#endif - { - for (typename Derived::Index index = start; index < end; ++index) - dst.copyCoeff(index, src); - } -}; - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - const Index size = dst.size(); - typedef packet_traits PacketTraits; - enum { - packetSize = PacketTraits::size, - dstAlignment = PacketTraits::AlignedOnScalar ? Aligned : int(assign_traits::DstIsAligned) , - srcAlignment = assign_traits::JointAlignment - }; - const Index alignedStart = assign_traits::DstIsAligned ? 0 - : internal::first_aligned(&dst.coeffRef(0), size); - const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize; - - unaligned_assign_impl::DstIsAligned!=0>::run(src,dst,0,alignedStart); - - for(Index index = alignedStart; index < alignedEnd; index += packetSize) - { - dst.template copyPacket(index, src); - } - - unaligned_assign_impl<>::run(src,dst,alignedEnd,size); - } -}; - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static IMP_EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src) - { - enum { size = Derived1::SizeAtCompileTime, - packetSize = packet_traits::size, - alignedSize = (size/packetSize)*packetSize }; - - assign_innervec_CompleteUnrolling::run(dst, src); - assign_DefaultTraversal_CompleteUnrolling::run(dst, src); - } -}; - -/************************** -*** Slice vectorization *** -***************************/ - -template -struct assign_impl -{ - typedef typename Derived1::Index Index; - static inline void run(Derived1 &dst, const Derived2 &src) - { - typedef typename Derived1::Scalar Scalar; - typedef packet_traits PacketTraits; - enum { - packetSize = PacketTraits::size, - alignable = PacketTraits::AlignedOnScalar, - dstIsAligned = assign_traits::DstIsAligned, - dstAlignment = alignable ? Aligned : int(dstIsAligned), - srcAlignment = assign_traits::JointAlignment - }; - const Scalar *dst_ptr = &dst.coeffRef(0,0); - if((!bool(dstIsAligned)) && (size_t(dst_ptr) % sizeof(Scalar))>0) - { - // the pointer is not aligend-on scalar, so alignment is not possible - return assign_impl::run(dst, src); - } - const Index packetAlignedMask = packetSize - 1; - const Index innerSize = dst.innerSize(); - const Index outerSize = dst.outerSize(); - const Index alignedStep = alignable ? (packetSize - dst.outerStride() % packetSize) & packetAlignedMask : 0; - Index alignedStart = ((!alignable) || bool(dstIsAligned)) ? 0 : internal::first_aligned(dst_ptr, innerSize); - - for(Index outer = 0; outer < outerSize; ++outer) - { - const Index alignedEnd = alignedStart + ((innerSize-alignedStart) & ~packetAlignedMask); - // do the non-vectorizable part of the assignment - for(Index inner = 0; inner(outer, inner, src); - - // do the non-vectorizable part of the assignment - for(Index inner = alignedEnd; inner((alignedStart+alignedStep)%packetSize, innerSize); - } - } -}; - -} // end namespace internal - -/*************************************************************************** -* Part 4 : implementation of DenseBase methods -***************************************************************************/ - -template -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase - ::lazyAssign(const DenseBase& other) -{ - enum{ - SameType = internal::is_same::value - }; - - IMP_EIGEN_STATIC_ASSERT_LVALUE(Derived) - IMP_EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) - IMP_EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - -#ifdef IMP_EIGEN_DEBUG_ASSIGN - internal::assign_traits::debug(); -#endif - imp_eigen_assert(rows() == other.rows() && cols() == other.cols()); - internal::assign_impl::Traversal) - : int(InvalidTraversal)>::run(derived(),other.derived()); -#ifndef IMP_EIGEN_NO_DEBUG - checkTransposeAliasing(other.derived()); -#endif - return derived(); -} - -namespace internal { - -template::Flags) & EvalBeforeAssigningBit) != 0, - bool NeedToTranspose = ((int(Derived::RowsAtCompileTime) == 1 && int(OtherDerived::ColsAtCompileTime) == 1) - | // FIXME | instead of || to please GCC 4.4.0 stupid warning "suggest parentheses around &&". - // revert to || as soon as not needed anymore. - (int(Derived::ColsAtCompileTime) == 1 && int(OtherDerived::RowsAtCompileTime) == 1)) - && int(Derived::SizeAtCompileTime) != 1> -struct assign_selector; - -template -struct assign_selector { - static IMP_EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.derived()); } - template - static IMP_EIGEN_STRONG_INLINE Derived& evalTo(ActualDerived& dst, const ActualOtherDerived& other) { other.evalTo(dst); return dst; } -}; -template -struct assign_selector { - static IMP_EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.eval()); } -}; -template -struct assign_selector { - static IMP_EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose()); } - template - static IMP_EIGEN_STRONG_INLINE Derived& evalTo(ActualDerived& dst, const ActualOtherDerived& other) { Transpose dstTrans(dst); other.evalTo(dstTrans); return dst; } -}; -template -struct assign_selector { - static IMP_EIGEN_STRONG_INLINE Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose().eval()); } -}; - -} // end namespace internal - -template -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) -{ - return internal::assign_selector::run(derived(), other.derived()); -} - -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) -{ - return internal::assign_selector::run(derived(), other.derived()); -} - -template -IMP_EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const MatrixBase& other) -{ - return internal::assign_selector::run(derived(), other.derived()); -} - -template -template -IMP_EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const DenseBase& other) -{ - return internal::assign_selector::run(derived(), other.derived()); -} - -template -template -IMP_EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const EigenBase& other) -{ - return internal::assign_selector::evalTo(derived(), other.derived()); -} - -template -template -IMP_EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const ReturnByValue& other) -{ - return internal::assign_selector::evalTo(derived(), other.derived()); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_ASSIGN_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Assign_MKL.h b/modules/algebra/include/eigen3/Eigen/src/Core/Assign_MKL.h deleted file mode 100644 index 6a9078b1f8..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Assign_MKL.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - Copyright (c) 2011, Intel Corporation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors may - be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - ******************************************************************************** - * Content : Eigen bindings to Intel(R) MKL - * MKL VML support for coefficient-wise unary Eigen expressions like a=b.sin() - ******************************************************************************** -*/ - -#ifndef IMP_EIGEN_ASSIGN_VML_H -#define IMP_EIGEN_ASSIGN_VML_H - -namespace IMP_Eigen { - -namespace internal { - -template struct vml_call -{ enum { IsSupported = 0 }; }; - -template -class vml_assign_traits -{ - private: - enum { - DstHasDirectAccess = Dst::Flags & DirectAccessBit, - SrcHasDirectAccess = Src::Flags & DirectAccessBit, - - StorageOrdersAgree = (int(Dst::IsRowMajor) == int(Src::IsRowMajor)), - InnerSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::SizeAtCompileTime) - : int(Dst::Flags)&RowMajorBit ? int(Dst::ColsAtCompileTime) - : int(Dst::RowsAtCompileTime), - InnerMaxSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::MaxSizeAtCompileTime) - : int(Dst::Flags)&RowMajorBit ? int(Dst::MaxColsAtCompileTime) - : int(Dst::MaxRowsAtCompileTime), - MaxSizeAtCompileTime = Dst::SizeAtCompileTime, - - MightEnableVml = vml_call::IsSupported && StorageOrdersAgree && DstHasDirectAccess && SrcHasDirectAccess - && Src::InnerStrideAtCompileTime==1 && Dst::InnerStrideAtCompileTime==1, - MightLinearize = MightEnableVml && (int(Dst::Flags) & int(Src::Flags) & LinearAccessBit), - VmlSize = MightLinearize ? MaxSizeAtCompileTime : InnerMaxSize, - LargeEnough = VmlSize==Dynamic || VmlSize>=IMP_EIGEN_MKL_VML_THRESHOLD, - MayEnableVml = MightEnableVml && LargeEnough, - MayLinearize = MayEnableVml && MightLinearize - }; - public: - enum { - Traversal = MayLinearize ? LinearVectorizedTraversal - : MayEnableVml ? InnerVectorizedTraversal - : DefaultTraversal - }; -}; - -template::Traversal > -struct vml_assign_impl - : assign_impl,Traversal,Unrolling,BuiltIn> -{ -}; - -template -struct vml_assign_impl -{ - typedef typename Derived1::Scalar Scalar; - typedef typename Derived1::Index Index; - static inline void run(Derived1& dst, const CwiseUnaryOp& src) - { - // in case we want to (or have to) skip VML at runtime we can call: - // assign_impl,Traversal,Unrolling,BuiltIn>::run(dst,src); - const Index innerSize = dst.innerSize(); - const Index outerSize = dst.outerSize(); - for(Index outer = 0; outer < outerSize; ++outer) { - const Scalar *src_ptr = src.IsRowMajor ? &(src.nestedExpression().coeffRef(outer,0)) : - &(src.nestedExpression().coeffRef(0, outer)); - Scalar *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer,0)) : &(dst.coeffRef(0, outer)); - vml_call::run(src.functor(), innerSize, src_ptr, dst_ptr ); - } - } -}; - -template -struct vml_assign_impl -{ - static inline void run(Derived1& dst, const CwiseUnaryOp& src) - { - // in case we want to (or have to) skip VML at runtime we can call: - // assign_impl,Traversal,Unrolling,BuiltIn>::run(dst,src); - vml_call::run(src.functor(), dst.size(), src.nestedExpression().data(), dst.data() ); - } -}; - -// Macroses - -#define IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(TRAVERSAL,UNROLLING) \ - template \ - struct assign_impl, TRAVERSAL, UNROLLING, Specialized> { \ - static inline void run(Derived1 &dst, const IMP_Eigen::CwiseUnaryOp &src) { \ - vml_assign_impl::run(dst, src); \ - } \ - }; - -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(DefaultTraversal,NoUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(DefaultTraversal,CompleteUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(DefaultTraversal,InnerUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(LinearTraversal,NoUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(LinearTraversal,CompleteUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(InnerVectorizedTraversal,NoUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(InnerVectorizedTraversal,CompleteUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(InnerVectorizedTraversal,InnerUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(LinearVectorizedTraversal,CompleteUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(LinearVectorizedTraversal,NoUnrolling) -IMP_EIGEN_MKL_VML_SPECIALIZE_ASSIGN(SliceVectorizedTraversal,NoUnrolling) - - -#if !defined (IMP_EIGEN_FAST_MATH) || (IMP_EIGEN_FAST_MATH != 1) -#define IMP_EIGEN_MKL_VML_MODE VML_HA -#else -#define IMP_EIGEN_MKL_VML_MODE VML_LA -#endif - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL(IMP_EIGENOP, VMLOP, IMP_EIGENTYPE, VMLTYPE) \ - template<> struct vml_call< scalar_##EIGENOP##_op > { \ - enum { IsSupported = 1 }; \ - static inline void run( const scalar_##EIGENOP##_op& /*func*/, \ - int size, const IMP_EIGENTYPE* src, IMP_EIGENTYPE* dst) { \ - VMLOP(size, (const VMLTYPE*)src, (VMLTYPE*)dst); \ - } \ - }; - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(IMP_EIGENOP, VMLOP, IMP_EIGENTYPE, VMLTYPE) \ - template<> struct vml_call< scalar_##EIGENOP##_op > { \ - enum { IsSupported = 1 }; \ - static inline void run( const scalar_##EIGENOP##_op& /*func*/, \ - int size, const IMP_EIGENTYPE* src, IMP_EIGENTYPE* dst) { \ - MKL_INT64 vmlMode = IMP_EIGEN_MKL_VML_MODE; \ - VMLOP(size, (const VMLTYPE*)src, (VMLTYPE*)dst, vmlMode); \ - } \ - }; - -#define IMP_EIGEN_MKL_VML_DECLARE_POW_CALL(IMP_EIGENOP, VMLOP, IMP_EIGENTYPE, VMLTYPE) \ - template<> struct vml_call< scalar_##EIGENOP##_op > { \ - enum { IsSupported = 1 }; \ - static inline void run( const scalar_##EIGENOP##_op& func, \ - int size, const IMP_EIGENTYPE* src, IMP_EIGENTYPE* dst) { \ - IMP_EIGENTYPE exponent = func.m_exponent; \ - MKL_INT64 vmlMode = IMP_EIGEN_MKL_VML_MODE; \ - VMLOP(&size, (const VMLTYPE*)src, (const VMLTYPE*)&exponent, \ - (VMLTYPE*)dst, &vmlMode); \ - } \ - }; - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL(IMP_EIGENOP, vs##VMLOP, float, float) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL(IMP_EIGENOP, vd##VMLOP, double, double) - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL(IMP_EIGENOP, vc##VMLOP, scomplex, MKL_Complex8) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL(IMP_EIGENOP, vz##VMLOP, dcomplex, MKL_Complex16) - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX(IMP_EIGENOP, VMLOP) - - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL_LA(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(IMP_EIGENOP, vms##VMLOP, float, float) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(IMP_EIGENOP, vmd##VMLOP, double, double) - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX_LA(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(IMP_EIGENOP, vmc##VMLOP, scomplex, MKL_Complex8) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(IMP_EIGENOP, vmz##VMLOP, dcomplex, MKL_Complex16) - -#define IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL_LA(IMP_EIGENOP, VMLOP) \ - IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX_LA(IMP_EIGENOP, VMLOP) - - -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(sin, Sin) -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(asin, Asin) -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(cos, Cos) -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(acos, Acos) -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(tan, Tan) -//EIGEN_MKL_VML_DECLARE_UNARY_CALLS(abs, Abs) -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(exp, Exp) -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(log, Ln) -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(sqrt, Sqrt) - -IMP_EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(square, Sqr) - -// The vm*powx functions are not avaibale in the windows version of MKL. -#ifndef _WIN32 -IMP_EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmspowx_, float, float) -IMP_EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmdpowx_, double, double) -IMP_EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmcpowx_, scomplex, MKL_Complex8) -IMP_EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmzpowx_, dcomplex, MKL_Complex16) -#endif - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_ASSIGN_VML_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/BandMatrix.h b/modules/algebra/include/eigen3/Eigen/src/Core/BandMatrix.h deleted file mode 100644 index 8625481d32..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/BandMatrix.h +++ /dev/null @@ -1,334 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_BANDMATRIX_H -#define IMP_EIGEN_BANDMATRIX_H - -namespace IMP_Eigen { - -namespace internal { - -template -class BandMatrixBase : public EigenBase -{ - public: - - enum { - Flags = internal::traits::Flags, - CoeffReadCost = internal::traits::CoeffReadCost, - RowsAtCompileTime = internal::traits::RowsAtCompileTime, - ColsAtCompileTime = internal::traits::ColsAtCompileTime, - MaxRowsAtCompileTime = internal::traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = internal::traits::MaxColsAtCompileTime, - Supers = internal::traits::Supers, - Subs = internal::traits::Subs, - Options = internal::traits::Options - }; - typedef typename internal::traits::Scalar Scalar; - typedef Matrix DenseMatrixType; - typedef typename DenseMatrixType::Index Index; - typedef typename internal::traits::CoefficientsType CoefficientsType; - typedef EigenBase Base; - - protected: - enum { - DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic)) - ? 1 + Supers + Subs - : Dynamic, - SizeAtCompileTime = IMP_EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime,ColsAtCompileTime) - }; - - public: - - using Base::derived; - using Base::rows; - using Base::cols; - - /** \returns the number of super diagonals */ - inline Index supers() const { return derived().supers(); } - - /** \returns the number of sub diagonals */ - inline Index subs() const { return derived().subs(); } - - /** \returns an expression of the underlying coefficient matrix */ - inline const CoefficientsType& coeffs() const { return derived().coeffs(); } - - /** \returns an expression of the underlying coefficient matrix */ - inline CoefficientsType& coeffs() { return derived().coeffs(); } - - /** \returns a vector expression of the \a i -th column, - * only the meaningful part is returned. - * \warning the internal storage must be column major. */ - inline Block col(Index i) - { - IMP_EIGEN_STATIC_ASSERT((Options&RowMajor)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); - Index start = 0; - Index len = coeffs().rows(); - if (i<=supers()) - { - start = supers()-i; - len = (std::min)(rows(),std::max(0,coeffs().rows() - (supers()-i))); - } - else if (i>=rows()-subs()) - len = std::max(0,coeffs().rows() - (i + 1 - rows() + subs())); - return Block(coeffs(), start, i, len, 1); - } - - /** \returns a vector expression of the main diagonal */ - inline Block diagonal() - { return Block(coeffs(),supers(),0,1,(std::min)(rows(),cols())); } - - /** \returns a vector expression of the main diagonal (const version) */ - inline const Block diagonal() const - { return Block(coeffs(),supers(),0,1,(std::min)(rows(),cols())); } - - template struct DiagonalIntReturnType { - enum { - ReturnOpposite = (Options&SelfAdjoint) && (((Index)>0 && Supers==0) || ((Index)<0 && Subs==0)), - Conjugate = ReturnOpposite && NumTraits::IsComplex, - ActualIndex = ReturnOpposite ? -Index : Index, - DiagonalSize = (RowsAtCompileTime==Dynamic || ColsAtCompileTime==Dynamic) - ? Dynamic - : (ActualIndex<0 - ? IMP_EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime, RowsAtCompileTime + ActualIndex) - : IMP_EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime, ColsAtCompileTime - ActualIndex)) - }; - typedef Block BuildType; - typedef typename internal::conditional,BuildType >, - BuildType>::type Type; - }; - - /** \returns a vector expression of the \a N -th sub or super diagonal */ - template inline typename DiagonalIntReturnType::Type diagonal() - { - return typename DiagonalIntReturnType::BuildType(coeffs(), supers()-N, (std::max)(0,N), 1, diagonalLength(N)); - } - - /** \returns a vector expression of the \a N -th sub or super diagonal */ - template inline const typename DiagonalIntReturnType::Type diagonal() const - { - return typename DiagonalIntReturnType::BuildType(coeffs(), supers()-N, (std::max)(0,N), 1, diagonalLength(N)); - } - - /** \returns a vector expression of the \a i -th sub or super diagonal */ - inline Block diagonal(Index i) - { - imp_eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers())); - return Block(coeffs(), supers()-i, std::max(0,i), 1, diagonalLength(i)); - } - - /** \returns a vector expression of the \a i -th sub or super diagonal */ - inline const Block diagonal(Index i) const - { - imp_eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers())); - return Block(coeffs(), supers()-i, std::max(0,i), 1, diagonalLength(i)); - } - - template inline void evalTo(Dest& dst) const - { - dst.resize(rows(),cols()); - dst.setZero(); - dst.diagonal() = diagonal(); - for (Index i=1; i<=supers();++i) - dst.diagonal(i) = diagonal(i); - for (Index i=1; i<=subs();++i) - dst.diagonal(-i) = diagonal(-i); - } - - DenseMatrixType toDenseMatrix() const - { - DenseMatrixType res(rows(),cols()); - evalTo(res); - return res; - } - - protected: - - inline Index diagonalLength(Index i) const - { return i<0 ? (std::min)(cols(),rows()+i) : (std::min)(rows(),cols()-i); } -}; - -/** - * \class BandMatrix - * \ingroup Core_Module - * - * \brief Represents a rectangular matrix with a banded storage - * - * \param _Scalar Numeric type, i.e. float, double, int - * \param Rows Number of rows, or \b Dynamic - * \param Cols Number of columns, or \b Dynamic - * \param Supers Number of super diagonal - * \param Subs Number of sub diagonal - * \param _Options A combination of either \b #RowMajor or \b #ColMajor, and of \b #SelfAdjoint - * The former controls \ref TopicStorageOrders "storage order", and defaults to - * column-major. The latter controls whether the matrix represents a selfadjoint - * matrix in which case either Supers of Subs have to be null. - * - * \sa class TridiagonalMatrix - */ - -template -struct traits > -{ - typedef _Scalar Scalar; - typedef Dense StorageKind; - typedef DenseIndex Index; - enum { - CoeffReadCost = NumTraits::ReadCost, - RowsAtCompileTime = _Rows, - ColsAtCompileTime = _Cols, - MaxRowsAtCompileTime = _Rows, - MaxColsAtCompileTime = _Cols, - Flags = LvalueBit, - Supers = _Supers, - Subs = _Subs, - Options = _Options, - DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic)) ? 1 + Supers + Subs : Dynamic - }; - typedef Matrix CoefficientsType; -}; - -template -class BandMatrix : public BandMatrixBase > -{ - public: - - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::CoefficientsType CoefficientsType; - - inline BandMatrix(Index rows=Rows, Index cols=Cols, Index supers=Supers, Index subs=Subs) - : m_coeffs(1+supers+subs,cols), - m_rows(rows), m_supers(supers), m_subs(subs) - { - } - - /** \returns the number of columns */ - inline Index rows() const { return m_rows.value(); } - - /** \returns the number of rows */ - inline Index cols() const { return m_coeffs.cols(); } - - /** \returns the number of super diagonals */ - inline Index supers() const { return m_supers.value(); } - - /** \returns the number of sub diagonals */ - inline Index subs() const { return m_subs.value(); } - - inline const CoefficientsType& coeffs() const { return m_coeffs; } - inline CoefficientsType& coeffs() { return m_coeffs; } - - protected: - - CoefficientsType m_coeffs; - internal::variable_if_dynamic m_rows; - internal::variable_if_dynamic m_supers; - internal::variable_if_dynamic m_subs; -}; - -template -class BandMatrixWrapper; - -template -struct traits > -{ - typedef typename _CoefficientsType::Scalar Scalar; - typedef typename _CoefficientsType::StorageKind StorageKind; - typedef typename _CoefficientsType::Index Index; - enum { - CoeffReadCost = internal::traits<_CoefficientsType>::CoeffReadCost, - RowsAtCompileTime = _Rows, - ColsAtCompileTime = _Cols, - MaxRowsAtCompileTime = _Rows, - MaxColsAtCompileTime = _Cols, - Flags = LvalueBit, - Supers = _Supers, - Subs = _Subs, - Options = _Options, - DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic)) ? 1 + Supers + Subs : Dynamic - }; - typedef _CoefficientsType CoefficientsType; -}; - -template -class BandMatrixWrapper : public BandMatrixBase > -{ - public: - - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::traits::CoefficientsType CoefficientsType; - typedef typename internal::traits::Index Index; - - inline BandMatrixWrapper(const CoefficientsType& coeffs, Index rows=_Rows, Index cols=_Cols, Index supers=_Supers, Index subs=_Subs) - : m_coeffs(coeffs), - m_rows(rows), m_supers(supers), m_subs(subs) - { - IMP_EIGEN_UNUSED_VARIABLE(cols); - //internal::assert(coeffs.cols()==cols() && (supers()+subs()+1)==coeffs.rows()); - } - - /** \returns the number of columns */ - inline Index rows() const { return m_rows.value(); } - - /** \returns the number of rows */ - inline Index cols() const { return m_coeffs.cols(); } - - /** \returns the number of super diagonals */ - inline Index supers() const { return m_supers.value(); } - - /** \returns the number of sub diagonals */ - inline Index subs() const { return m_subs.value(); } - - inline const CoefficientsType& coeffs() const { return m_coeffs; } - - protected: - - const CoefficientsType& m_coeffs; - internal::variable_if_dynamic m_rows; - internal::variable_if_dynamic m_supers; - internal::variable_if_dynamic m_subs; -}; - -/** - * \class TridiagonalMatrix - * \ingroup Core_Module - * - * \brief Represents a tridiagonal matrix with a compact banded storage - * - * \param _Scalar Numeric type, i.e. float, double, int - * \param Size Number of rows and cols, or \b Dynamic - * \param _Options Can be 0 or \b SelfAdjoint - * - * \sa class BandMatrix - */ -template -class TridiagonalMatrix : public BandMatrix -{ - typedef BandMatrix Base; - typedef typename Base::Index Index; - public: - TridiagonalMatrix(Index size = Size) : Base(size,size,Options&SelfAdjoint?0:1,1) {} - - inline typename Base::template DiagonalIntReturnType<1>::Type super() - { return Base::template diagonal<1>(); } - inline const typename Base::template DiagonalIntReturnType<1>::Type super() const - { return Base::template diagonal<1>(); } - inline typename Base::template DiagonalIntReturnType<-1>::Type sub() - { return Base::template diagonal<-1>(); } - inline const typename Base::template DiagonalIntReturnType<-1>::Type sub() const - { return Base::template diagonal<-1>(); } - protected: -}; - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_BANDMATRIX_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Block.h b/modules/algebra/include/eigen3/Eigen/src/Core/Block.h deleted file mode 100644 index 4893c31224..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Block.h +++ /dev/null @@ -1,406 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2006-2010 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_BLOCK_H -#define IMP_EIGEN_BLOCK_H - -namespace IMP_Eigen { - -/** \class Block - * \ingroup Core_Module - * - * \brief Expression of a fixed-size or dynamic-size block - * - * \param XprType the type of the expression in which we are taking a block - * \param BlockRows the number of rows of the block we are taking at compile time (optional) - * \param BlockCols the number of columns of the block we are taking at compile time (optional) - * - * This class represents an expression of either a fixed-size or dynamic-size block. It is the return - * type of DenseBase::block(Index,Index,Index,Index) and DenseBase::block(Index,Index) and - * most of the time this is the only way it is used. - * - * However, if you want to directly maniputate block expressions, - * for instance if you want to write a function returning such an expression, you - * will need to use this class. - * - * Here is an example illustrating the dynamic case: - * \include class_Block.cpp - * Output: \verbinclude class_Block.out - * - * \note Even though this expression has dynamic size, in the case where \a XprType - * has fixed size, this expression inherits a fixed maximal size which means that evaluating - * it does not cause a dynamic memory allocation. - * - * Here is an example illustrating the fixed-size case: - * \include class_FixedBlock.cpp - * Output: \verbinclude class_FixedBlock.out - * - * \sa DenseBase::block(Index,Index,Index,Index), DenseBase::block(Index,Index), class VectorBlock - */ - -namespace internal { -template -struct traits > : traits -{ - typedef typename traits::Scalar Scalar; - typedef typename traits::StorageKind StorageKind; - typedef typename traits::XprKind XprKind; - typedef typename nested::type XprTypeNested; - typedef typename remove_reference::type _XprTypeNested; - enum{ - MatrixRows = traits::RowsAtCompileTime, - MatrixCols = traits::ColsAtCompileTime, - RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows, - ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols, - MaxRowsAtCompileTime = BlockRows==0 ? 0 - : RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) - : int(traits::MaxRowsAtCompileTime), - MaxColsAtCompileTime = BlockCols==0 ? 0 - : ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) - : int(traits::MaxColsAtCompileTime), - XprTypeIsRowMajor = (int(traits::Flags)&RowMajorBit) != 0, - IsDense = is_same::value, - IsRowMajor = (IsDense&&MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1 - : (IsDense&&MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0 - : XprTypeIsRowMajor, - HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor), - InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime), - InnerStrideAtCompileTime = HasSameStorageOrderAsXprType - ? int(inner_stride_at_compile_time::ret) - : int(outer_stride_at_compile_time::ret), - OuterStrideAtCompileTime = HasSameStorageOrderAsXprType - ? int(outer_stride_at_compile_time::ret) - : int(inner_stride_at_compile_time::ret), - MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % packet_traits::size) == 0) - && (InnerStrideAtCompileTime == 1) - ? PacketAccessBit : 0, - MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % 16) == 0)) ? AlignedBit : 0, - FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1 || (InnerPanel && (traits::Flags&LinearAccessBit))) ? LinearAccessBit : 0, - FlagsLvalueBit = is_lvalue::value ? LvalueBit : 0, - FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0, - Flags0 = traits::Flags & ( (HereditaryBits & ~RowMajorBit) | - DirectAccessBit | - MaskPacketAccessBit | - MaskAlignedBit), - Flags = Flags0 | FlagsLinearAccessBit | FlagsLvalueBit | FlagsRowMajorBit - }; -}; - -template::ret> class BlockImpl_dense; - -} // end namespace internal - -template class BlockImpl; - -template class Block - : public BlockImpl::StorageKind> -{ - typedef BlockImpl::StorageKind> Impl; - public: - //typedef typename Impl::Base Base; - typedef Impl Base; - IMP_EIGEN_GENERIC_PUBLIC_INTERFACE(Block) - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) - - /** Column or Row constructor - */ - inline Block(XprType& xpr, Index i) : Impl(xpr,i) - { - imp_eigen_assert( (i>=0) && ( - ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i= 0 && BlockRows >= 1 && a_startRow + BlockRows <= xpr.rows() - && a_startCol >= 0 && BlockCols >= 1 && a_startCol + BlockCols <= xpr.cols()); - } - - /** Dynamic-size constructor - */ - inline Block(XprType& xpr, - Index a_startRow, Index a_startCol, - Index blockRows, Index blockCols) - : Impl(xpr, a_startRow, a_startCol, blockRows, blockCols) - { - imp_eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) - && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); - imp_eigen_assert(a_startRow >= 0 && blockRows >= 0 && a_startRow <= xpr.rows() - blockRows - && a_startCol >= 0 && blockCols >= 0 && a_startCol <= xpr.cols() - blockCols); - } -}; - -// The generic default implementation for dense block simplu forward to the internal::BlockImpl_dense -// that must be specialized for direct and non-direct access... -template -class BlockImpl - : public internal::BlockImpl_dense -{ - typedef internal::BlockImpl_dense Impl; - typedef typename XprType::Index Index; - public: - typedef Impl Base; - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl) - inline BlockImpl(XprType& xpr, Index i) : Impl(xpr,i) {} - inline BlockImpl(XprType& xpr, Index a_startRow, Index a_startCol) : Impl(xpr, a_startRow, a_startCol) {} - inline BlockImpl(XprType& xpr, Index a_startRow, Index a_startCol, Index blockRows, Index blockCols) - : Impl(xpr, a_startRow, a_startCol, blockRows, blockCols) {} -}; - -namespace internal { - -/** \internal Internal implementation of dense Blocks in the general case. */ -template class BlockImpl_dense - : public internal::dense_xpr_base >::type -{ - typedef Block BlockType; - public: - - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(BlockType) - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense) - - class InnerIterator; - - /** Column or Row constructor - */ - inline BlockImpl_dense(XprType& xpr, Index i) - : m_xpr(xpr), - // It is a row if and only if BlockRows==1 and BlockCols==XprType::ColsAtCompileTime, - // and it is a column if and only if BlockRows==XprType::RowsAtCompileTime and BlockCols==1, - // all other cases are invalid. - // The case a 1x1 matrix seems ambiguous, but the result is the same anyway. - m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0), - m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), - m_blockRows(BlockRows==1 ? 1 : xpr.rows()), - m_blockCols(BlockCols==1 ? 1 : xpr.cols()) - {} - - /** Fixed-size constructor - */ - inline BlockImpl_dense(XprType& xpr, Index a_startRow, Index a_startCol) - : m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol), - m_blockRows(BlockRows), m_blockCols(BlockCols) - {} - - /** Dynamic-size constructor - */ - inline BlockImpl_dense(XprType& xpr, - Index a_startRow, Index a_startCol, - Index blockRows, Index blockCols) - : m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol), - m_blockRows(blockRows), m_blockCols(blockCols) - {} - - inline Index rows() const { return m_blockRows.value(); } - inline Index cols() const { return m_blockCols.value(); } - - inline Scalar& coeffRef(Index rowId, Index colId) - { - IMP_EIGEN_STATIC_ASSERT_LVALUE(XprType) - return m_xpr.const_cast_derived() - .coeffRef(rowId + m_startRow.value(), colId + m_startCol.value()); - } - - inline const Scalar& coeffRef(Index rowId, Index colId) const - { - return m_xpr.derived() - .coeffRef(rowId + m_startRow.value(), colId + m_startCol.value()); - } - - IMP_EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index rowId, Index colId) const - { - return m_xpr.coeff(rowId + m_startRow.value(), colId + m_startCol.value()); - } - - inline Scalar& coeffRef(Index index) - { - IMP_EIGEN_STATIC_ASSERT_LVALUE(XprType) - return m_xpr.const_cast_derived() - .coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), - m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); - } - - inline const Scalar& coeffRef(Index index) const - { - return m_xpr.const_cast_derived() - .coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), - m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); - } - - inline const CoeffReturnType coeff(Index index) const - { - return m_xpr - .coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), - m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); - } - - template - inline PacketScalar packet(Index rowId, Index colId) const - { - return m_xpr.template packet - (rowId + m_startRow.value(), colId + m_startCol.value()); - } - - template - inline void writePacket(Index rowId, Index colId, const PacketScalar& val) - { - m_xpr.const_cast_derived().template writePacket - (rowId + m_startRow.value(), colId + m_startCol.value(), val); - } - - template - inline PacketScalar packet(Index index) const - { - return m_xpr.template packet - (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), - m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); - } - - template - inline void writePacket(Index index, const PacketScalar& val) - { - m_xpr.const_cast_derived().template writePacket - (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), - m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0), val); - } - - #ifdef IMP_EIGEN_PARSED_BY_DOXYGEN - /** \sa MapBase::data() */ - inline const Scalar* data() const; - inline Index innerStride() const; - inline Index outerStride() const; - #endif - - const typename internal::remove_all::type& nestedExpression() const - { - return m_xpr; - } - - Index startRow() const - { - return m_startRow.value(); - } - - Index startCol() const - { - return m_startCol.value(); - } - - protected: - - const typename XprType::Nested m_xpr; - const internal::variable_if_dynamic m_startRow; - const internal::variable_if_dynamic m_startCol; - const internal::variable_if_dynamic m_blockRows; - const internal::variable_if_dynamic m_blockCols; -}; - -/** \internal Internal implementation of dense Blocks in the direct access case.*/ -template -class BlockImpl_dense - : public MapBase > -{ - typedef Block BlockType; - public: - - typedef MapBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(BlockType) - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense) - - /** Column or Row constructor - */ - inline BlockImpl_dense(XprType& xpr, Index i) - : Base(internal::const_cast_ptr(&xpr.coeffRef( - (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0, - (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0)), - BlockRows==1 ? 1 : xpr.rows(), - BlockCols==1 ? 1 : xpr.cols()), - m_xpr(xpr) - { - init(); - } - - /** Fixed-size constructor - */ - inline BlockImpl_dense(XprType& xpr, Index startRow, Index startCol) - : Base(internal::const_cast_ptr(&xpr.coeffRef(startRow,startCol))), m_xpr(xpr) - { - init(); - } - - /** Dynamic-size constructor - */ - inline BlockImpl_dense(XprType& xpr, - Index startRow, Index startCol, - Index blockRows, Index blockCols) - : Base(internal::const_cast_ptr(&xpr.coeffRef(startRow,startCol)), blockRows, blockCols), - m_xpr(xpr) - { - init(); - } - - const typename internal::remove_all::type& nestedExpression() const - { - return m_xpr; - } - - /** \sa MapBase::innerStride() */ - inline Index innerStride() const - { - return internal::traits::HasSameStorageOrderAsXprType - ? m_xpr.innerStride() - : m_xpr.outerStride(); - } - - /** \sa MapBase::outerStride() */ - inline Index outerStride() const - { - return m_outerStride; - } - - #ifndef __SUNPRO_CC - // FIXME sunstudio is not friendly with the above friend... - // META-FIXME there is no 'friend' keyword around here. Is this obsolete? - protected: - #endif - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** \internal used by allowAligned() */ - inline BlockImpl_dense(XprType& xpr, const Scalar* data, Index blockRows, Index blockCols) - : Base(data, blockRows, blockCols), m_xpr(xpr) - { - init(); - } - #endif - - protected: - void init() - { - m_outerStride = internal::traits::HasSameStorageOrderAsXprType - ? m_xpr.outerStride() - : m_xpr.innerStride(); - } - - typename XprType::Nested m_xpr; - Index m_outerStride; -}; - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_BLOCK_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/BooleanRedux.h b/modules/algebra/include/eigen3/Eigen/src/Core/BooleanRedux.h deleted file mode 100644 index c8d06a2688..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/BooleanRedux.h +++ /dev/null @@ -1,154 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_ALLANDANY_H -#define IMP_EIGEN_ALLANDANY_H - -namespace IMP_Eigen { - -namespace internal { - -template -struct all_unroller -{ - enum { - col = (UnrollCount-1) / Derived::RowsAtCompileTime, - row = (UnrollCount-1) % Derived::RowsAtCompileTime - }; - - static inline bool run(const Derived &mat) - { - return all_unroller::run(mat) && mat.coeff(row, col); - } -}; - -template -struct all_unroller -{ - static inline bool run(const Derived &/*mat*/) { return true; } -}; - -template -struct all_unroller -{ - static inline bool run(const Derived &) { return false; } -}; - -template -struct any_unroller -{ - enum { - col = (UnrollCount-1) / Derived::RowsAtCompileTime, - row = (UnrollCount-1) % Derived::RowsAtCompileTime - }; - - static inline bool run(const Derived &mat) - { - return any_unroller::run(mat) || mat.coeff(row, col); - } -}; - -template -struct any_unroller -{ - static inline bool run(const Derived & /*mat*/) { return false; } -}; - -template -struct any_unroller -{ - static inline bool run(const Derived &) { return false; } -}; - -} // end namespace internal - -/** \returns true if all coefficients are true - * - * Example: \include MatrixBase_all.cpp - * Output: \verbinclude MatrixBase_all.out - * - * \sa any(), Cwise::operator<() - */ -template -inline bool DenseBase::all() const -{ - enum { - unroll = SizeAtCompileTime != Dynamic - && CoeffReadCost != Dynamic - && NumTraits::AddCost != Dynamic - && SizeAtCompileTime * (CoeffReadCost + NumTraits::AddCost) <= IMP_EIGEN_UNROLLING_LIMIT - }; - if(unroll) - return internal::all_unroller::run(derived()); - else - { - for(Index j = 0; j < cols(); ++j) - for(Index i = 0; i < rows(); ++i) - if (!coeff(i, j)) return false; - return true; - } -} - -/** \returns true if at least one coefficient is true - * - * \sa all() - */ -template -inline bool DenseBase::any() const -{ - enum { - unroll = SizeAtCompileTime != Dynamic - && CoeffReadCost != Dynamic - && NumTraits::AddCost != Dynamic - && SizeAtCompileTime * (CoeffReadCost + NumTraits::AddCost) <= IMP_EIGEN_UNROLLING_LIMIT - }; - if(unroll) - return internal::any_unroller::run(derived()); - else - { - for(Index j = 0; j < cols(); ++j) - for(Index i = 0; i < rows(); ++i) - if (coeff(i, j)) return true; - return false; - } -} - -/** \returns the number of coefficients which evaluate to true - * - * \sa all(), any() - */ -template -inline typename DenseBase::Index DenseBase::count() const -{ - return derived().template cast().template cast().sum(); -} - -/** \returns true is \c *this contains at least one Not A Number (NaN). - * - * \sa allFinite() - */ -template -inline bool DenseBase::hasNaN() const -{ - return !((derived().array()==derived().array()).all()); -} - -/** \returns true if \c *this contains only finite numbers, i.e., no NaN and no +/-INF values. - * - * \sa hasNaN() - */ -template -inline bool DenseBase::allFinite() const -{ - return !((derived()-derived()).hasNaN()); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_ALLANDANY_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/CommaInitializer.h b/modules/algebra/include/eigen3/Eigen/src/Core/CommaInitializer.h deleted file mode 100644 index e0bc616a80..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/CommaInitializer.h +++ /dev/null @@ -1,157 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2006-2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_COMMAINITIALIZER_H -#define IMP_EIGEN_COMMAINITIALIZER_H - -namespace IMP_Eigen { - -/** \class CommaInitializer - * \ingroup Core_Module - * - * \brief Helper class used by the comma initializer operator - * - * This class is internally used to implement the comma initializer feature. It is - * the return type of MatrixBase::operator<<, and most of the time this is the only - * way it is used. - * - * \sa \ref MatrixBaseCommaInitRef "MatrixBase::operator<<", CommaInitializer::finished() - */ -template -struct CommaInitializer -{ - typedef typename XprType::Scalar Scalar; - typedef typename XprType::Index Index; - - inline CommaInitializer(XprType& xpr, const Scalar& s) - : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1) - { - m_xpr.coeffRef(0,0) = s; - } - - template - inline CommaInitializer(XprType& xpr, const DenseBase& other) - : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows()) - { - m_xpr.block(0, 0, other.rows(), other.cols()) = other; - } - - /* Copy/Move constructor which transfers ownership. This is crucial in - * absence of return value optimization to avoid assertions during destruction. */ - // FIXME in C++11 mode this could be replaced by a proper RValue constructor - inline CommaInitializer(const CommaInitializer& o) - : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) { - // Mark original object as finished. In absence of R-value references we need to const_cast: - const_cast(o).m_row = m_xpr.rows(); - const_cast(o).m_col = m_xpr.cols(); - const_cast(o).m_currentBlockRows = 0; - } - - /* inserts a scalar value in the target matrix */ - CommaInitializer& operator,(const Scalar& s) - { - if (m_col==m_xpr.cols()) - { - m_row+=m_currentBlockRows; - m_col = 0; - m_currentBlockRows = 1; - imp_eigen_assert(m_row - CommaInitializer& operator,(const DenseBase& other) - { - if(other.rows()==0) - { - m_col += other.cols(); - return *this; - } - if (m_col==m_xpr.cols()) - { - m_row+=m_currentBlockRows; - m_col = 0; - m_currentBlockRows = other.rows(); - imp_eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows() - && "Too many rows passed to comma initializer (operator<<)"); - } - imp_eigen_assert((m_col - (m_row, m_col) = other; - else - m_xpr.block(m_row, m_col, other.rows(), other.cols()) = other; - m_col += other.cols(); - return *this; - } - - inline ~CommaInitializer() - { - imp_eigen_assert((m_row+m_currentBlockRows) == m_xpr.rows() - && m_col == m_xpr.cols() - && "Too few coefficients passed to comma initializer (operator<<)"); - } - - /** \returns the built matrix once all its coefficients have been set. - * Calling finished is 100% optional. Its purpose is to write expressions - * like this: - * \code - * quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished()); - * \endcode - */ - inline XprType& finished() { return m_xpr; } - - XprType& m_xpr; // target expression - Index m_row; // current row id - Index m_col; // current col id - Index m_currentBlockRows; // current block height -}; - -/** \anchor MatrixBaseCommaInitRef - * Convenient operator to set the coefficients of a matrix. - * - * The coefficients must be provided in a row major order and exactly match - * the size of the matrix. Otherwise an assertion is raised. - * - * Example: \include MatrixBase_set.cpp - * Output: \verbinclude MatrixBase_set.out - * - * \note According the c++ standard, the argument expressions of this comma initializer are evaluated in arbitrary order. - * - * \sa CommaInitializer::finished(), class CommaInitializer - */ -template -inline CommaInitializer DenseBase::operator<< (const Scalar& s) -{ - return CommaInitializer(*static_cast(this), s); -} - -/** \sa operator<<(const Scalar&) */ -template -template -inline CommaInitializer -DenseBase::operator<<(const DenseBase& other) -{ - return CommaInitializer(*static_cast(this), other); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_COMMAINITIALIZER_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/CoreIterators.h b/modules/algebra/include/eigen3/Eigen/src/Core/CoreIterators.h deleted file mode 100644 index f370acb337..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/CoreIterators.h +++ /dev/null @@ -1,61 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_COREITERATORS_H -#define IMP_EIGEN_COREITERATORS_H - -namespace IMP_Eigen { - -/* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core - */ - -/** \ingroup SparseCore_Module - * \class InnerIterator - * \brief An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression - * - * todo - */ - -// generic version for dense matrix and expressions -template class DenseBase::InnerIterator -{ - protected: - typedef typename Derived::Scalar Scalar; - typedef typename Derived::Index Index; - - enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit }; - public: - IMP_EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer) - : m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize()) - {} - - IMP_EIGEN_STRONG_INLINE Scalar value() const - { - return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner) - : m_expression.coeff(m_inner, m_outer); - } - - IMP_EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; } - - IMP_EIGEN_STRONG_INLINE Index index() const { return m_inner; } - inline Index row() const { return IsRowMajor ? m_outer : index(); } - inline Index col() const { return IsRowMajor ? index() : m_outer; } - - IMP_EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; } - - protected: - const Derived& m_expression; - Index m_inner; - const Index m_outer; - const Index m_end; -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_COREITERATORS_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h b/modules/algebra/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h deleted file mode 100644 index 28fabedddf..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h +++ /dev/null @@ -1,230 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2009 Gael Guennebaud -// Copyright (C) 2006-2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_CWISE_BINARY_OP_H -#define IMP_EIGEN_CWISE_BINARY_OP_H - -namespace IMP_Eigen { - -/** \class CwiseBinaryOp - * \ingroup Core_Module - * - * \brief Generic expression where a coefficient-wise binary operator is applied to two expressions - * - * \param BinaryOp template functor implementing the operator - * \param Lhs the type of the left-hand side - * \param Rhs the type of the right-hand side - * - * This class represents an expression where a coefficient-wise binary operator is applied to two expressions. - * It is the return type of binary operators, by which we mean only those binary operators where - * both the left-hand side and the right-hand side are Eigen expressions. - * For example, the return type of matrix1+matrix2 is a CwiseBinaryOp. - * - * Most of the time, this is the only way that it is used, so you typically don't have to name - * CwiseBinaryOp types explicitly. - * - * \sa MatrixBase::binaryExpr(const MatrixBase &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp - */ - -namespace internal { -template -struct traits > -{ - // we must not inherit from traits since it has - // the potential to cause problems with MSVC - typedef typename remove_all::type Ancestor; - typedef typename traits::XprKind XprKind; - enum { - RowsAtCompileTime = traits::RowsAtCompileTime, - ColsAtCompileTime = traits::ColsAtCompileTime, - MaxRowsAtCompileTime = traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = traits::MaxColsAtCompileTime - }; - - // even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor), - // we still want to handle the case when the result type is different. - typedef typename result_of< - BinaryOp( - typename Lhs::Scalar, - typename Rhs::Scalar - ) - >::type Scalar; - typedef typename promote_storage_type::StorageKind, - typename traits::StorageKind>::ret StorageKind; - typedef typename promote_index_type::Index, - typename traits::Index>::type Index; - typedef typename Lhs::Nested LhsNested; - typedef typename Rhs::Nested RhsNested; - typedef typename remove_reference::type _LhsNested; - typedef typename remove_reference::type _RhsNested; - enum { - LhsCoeffReadCost = _LhsNested::CoeffReadCost, - RhsCoeffReadCost = _RhsNested::CoeffReadCost, - LhsFlags = _LhsNested::Flags, - RhsFlags = _RhsNested::Flags, - SameType = is_same::value, - StorageOrdersAgree = (int(Lhs::Flags)&RowMajorBit)==(int(Rhs::Flags)&RowMajorBit), - Flags0 = (int(LhsFlags) | int(RhsFlags)) & ( - HereditaryBits - | (int(LhsFlags) & int(RhsFlags) & - ( AlignedBit - | (StorageOrdersAgree ? LinearAccessBit : 0) - | (functor_traits::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0) - ) - ) - ), - Flags = (Flags0 & ~RowMajorBit) | (LhsFlags & RowMajorBit), - Cost0 = IMP_EIGEN_ADD_COST(LhsCoeffReadCost,RhsCoeffReadCost), - CoeffReadCost = IMP_EIGEN_ADD_COST(Cost0,functor_traits::Cost) - }; -}; -} // end namespace internal - -// we require Lhs and Rhs to have the same scalar type. Currently there is no example of a binary functor -// that would take two operands of different types. If there were such an example, then this check should be -// moved to the BinaryOp functors, on a per-case basis. This would however require a change in the BinaryOp functors, as -// currently they take only one typename Scalar template parameter. -// It is tempting to always allow mixing different types but remember that this is often impossible in the vectorized paths. -// So allowing mixing different types gives very unexpected errors when enabling vectorization, when the user tries to -// add together a float matrix and a double matrix. -#define IMP_EIGEN_CHECK_BINARY_COMPATIBILIY(BINOP,LHS,RHS) \ - IMP_EIGEN_STATIC_ASSERT((internal::functor_is_product_like::ret \ - ? int(internal::scalar_product_traits::Defined) \ - : int(internal::is_same::value)), \ - YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - -template -class CwiseBinaryOpImpl; - -template -class CwiseBinaryOp : internal::no_assignment_operator, - public CwiseBinaryOpImpl< - BinaryOp, Lhs, Rhs, - typename internal::promote_storage_type::StorageKind, - typename internal::traits::StorageKind>::ret> -{ - public: - - typedef typename CwiseBinaryOpImpl< - BinaryOp, Lhs, Rhs, - typename internal::promote_storage_type::StorageKind, - typename internal::traits::StorageKind>::ret>::Base Base; - IMP_EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp) - - typedef typename internal::nested::type LhsNested; - typedef typename internal::nested::type RhsNested; - typedef typename internal::remove_reference::type _LhsNested; - typedef typename internal::remove_reference::type _RhsNested; - - IMP_EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs, const BinaryOp& func = BinaryOp()) - : m_lhs(aLhs), m_rhs(aRhs), m_functor(func) - { - IMP_EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar); - // require the sizes to match - IMP_EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs) - imp_eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()); - } - - IMP_EIGEN_STRONG_INLINE Index rows() const { - // return the fixed size type if available to enable compile time optimizations - if (internal::traits::type>::RowsAtCompileTime==Dynamic) - return m_rhs.rows(); - else - return m_lhs.rows(); - } - IMP_EIGEN_STRONG_INLINE Index cols() const { - // return the fixed size type if available to enable compile time optimizations - if (internal::traits::type>::ColsAtCompileTime==Dynamic) - return m_rhs.cols(); - else - return m_lhs.cols(); - } - - /** \returns the left hand side nested expression */ - const _LhsNested& lhs() const { return m_lhs; } - /** \returns the right hand side nested expression */ - const _RhsNested& rhs() const { return m_rhs; } - /** \returns the functor representing the binary operation */ - const BinaryOp& functor() const { return m_functor; } - - protected: - LhsNested m_lhs; - RhsNested m_rhs; - const BinaryOp m_functor; -}; - -template -class CwiseBinaryOpImpl - : public internal::dense_xpr_base >::type -{ - typedef CwiseBinaryOp Derived; - public: - - typedef typename internal::dense_xpr_base >::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE( Derived ) - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index rowId, Index colId) const - { - return derived().functor()(derived().lhs().coeff(rowId, colId), - derived().rhs().coeff(rowId, colId)); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const - { - return derived().functor().packetOp(derived().lhs().template packet(rowId, colId), - derived().rhs().template packet(rowId, colId)); - } - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index index) const - { - return derived().functor()(derived().lhs().coeff(index), - derived().rhs().coeff(index)); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index index) const - { - return derived().functor().packetOp(derived().lhs().template packet(index), - derived().rhs().template packet(index)); - } -}; - -/** replaces \c *this by \c *this - \a other. - * - * \returns a reference to \c *this - */ -template -template -IMP_EIGEN_STRONG_INLINE Derived & -MatrixBase::operator-=(const MatrixBase &other) -{ - SelfCwiseBinaryOp, Derived, OtherDerived> tmp(derived()); - tmp = other.derived(); - return derived(); -} - -/** replaces \c *this by \c *this + \a other. - * - * \returns a reference to \c *this - */ -template -template -IMP_EIGEN_STRONG_INLINE Derived & -MatrixBase::operator+=(const MatrixBase& other) -{ - SelfCwiseBinaryOp, Derived, OtherDerived> tmp(derived()); - tmp = other.derived(); - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_CWISE_BINARY_OP_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseNullaryOp.h b/modules/algebra/include/eigen3/Eigen/src/Core/CwiseNullaryOp.h deleted file mode 100644 index 152a08177e..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseNullaryOp.h +++ /dev/null @@ -1,864 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_CWISE_NULLARY_OP_H -#define IMP_EIGEN_CWISE_NULLARY_OP_H - -namespace IMP_Eigen { - -/** \class CwiseNullaryOp - * \ingroup Core_Module - * - * \brief Generic expression of a matrix where all coefficients are defined by a functor - * - * \param NullaryOp template functor implementing the operator - * \param PlainObjectType the underlying plain matrix/array type - * - * This class represents an expression of a generic nullary operator. - * It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() methods, - * and most of the time this is the only way it is used. - * - * However, if you want to write a function returning such an expression, you - * will need to use this class. - * - * \sa class CwiseUnaryOp, class CwiseBinaryOp, DenseBase::NullaryExpr() - */ - -namespace internal { -template -struct traits > : traits -{ - enum { - Flags = (traits::Flags - & ( HereditaryBits - | (functor_has_linear_access::ret ? LinearAccessBit : 0) - | (functor_traits::PacketAccess ? PacketAccessBit : 0))) - | (functor_traits::IsRepeatable ? 0 : EvalBeforeNestingBit), - CoeffReadCost = functor_traits::Cost - }; -}; -} - -template -class CwiseNullaryOp : internal::no_assignment_operator, - public internal::dense_xpr_base< CwiseNullaryOp >::type -{ - public: - - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp) - - CwiseNullaryOp(Index nbRows, Index nbCols, const NullaryOp& func = NullaryOp()) - : m_rows(nbRows), m_cols(nbCols), m_functor(func) - { - imp_eigen_assert(nbRows >= 0 - && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == nbRows) - && nbCols >= 0 - && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == nbCols)); - } - - IMP_EIGEN_STRONG_INLINE Index rows() const { return m_rows.value(); } - IMP_EIGEN_STRONG_INLINE Index cols() const { return m_cols.value(); } - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index rowId, Index colId) const - { - return m_functor(rowId, colId); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const - { - return m_functor.packetOp(rowId, colId); - } - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index index) const - { - return m_functor(index); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index index) const - { - return m_functor.packetOp(index); - } - - /** \returns the functor representing the nullary operation */ - const NullaryOp& functor() const { return m_functor; } - - protected: - const internal::variable_if_dynamic m_rows; - const internal::variable_if_dynamic m_cols; - const NullaryOp m_functor; -}; - - -/** \returns an expression of a matrix defined by a custom functor \a func - * - * The parameters \a rows and \a cols are the number of rows and of columns of - * the returned matrix. Must be compatible with this MatrixBase type. - * - * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used - * instead. - * - * The template parameter \a CustomNullaryOp is the type of the functor. - * - * \sa class CwiseNullaryOp - */ -template -template -IMP_EIGEN_STRONG_INLINE const CwiseNullaryOp -DenseBase::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func) -{ - return CwiseNullaryOp(rows, cols, func); -} - -/** \returns an expression of a matrix defined by a custom functor \a func - * - * The parameter \a size is the size of the returned vector. - * Must be compatible with this MatrixBase type. - * - * \only_for_vectors - * - * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so Zero() should be used - * instead. - * - * The template parameter \a CustomNullaryOp is the type of the functor. - * - * \sa class CwiseNullaryOp - */ -template -template -IMP_EIGEN_STRONG_INLINE const CwiseNullaryOp -DenseBase::NullaryExpr(Index size, const CustomNullaryOp& func) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - if(RowsAtCompileTime == 1) return CwiseNullaryOp(1, size, func); - else return CwiseNullaryOp(size, 1, func); -} - -/** \returns an expression of a matrix defined by a custom functor \a func - * - * This variant is only for fixed-size DenseBase types. For dynamic-size types, you - * need to use the variants taking size arguments. - * - * The template parameter \a CustomNullaryOp is the type of the functor. - * - * \sa class CwiseNullaryOp - */ -template -template -IMP_EIGEN_STRONG_INLINE const CwiseNullaryOp -DenseBase::NullaryExpr(const CustomNullaryOp& func) -{ - return CwiseNullaryOp(RowsAtCompileTime, ColsAtCompileTime, func); -} - -/** \returns an expression of a constant matrix of value \a value - * - * The parameters \a nbRows and \a nbCols are the number of rows and of columns of - * the returned matrix. Must be compatible with this DenseBase type. - * - * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a nbRows and \a nbCols as arguments, so Zero() should be used - * instead. - * - * The template parameter \a CustomNullaryOp is the type of the functor. - * - * \sa class CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Constant(Index nbRows, Index nbCols, const Scalar& value) -{ - return DenseBase::NullaryExpr(nbRows, nbCols, internal::scalar_constant_op(value)); -} - -/** \returns an expression of a constant matrix of value \a value - * - * The parameter \a size is the size of the returned vector. - * Must be compatible with this DenseBase type. - * - * \only_for_vectors - * - * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so Zero() should be used - * instead. - * - * The template parameter \a CustomNullaryOp is the type of the functor. - * - * \sa class CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Constant(Index size, const Scalar& value) -{ - return DenseBase::NullaryExpr(size, internal::scalar_constant_op(value)); -} - -/** \returns an expression of a constant matrix of value \a value - * - * This variant is only for fixed-size DenseBase types. For dynamic-size types, you - * need to use the variants taking size arguments. - * - * The template parameter \a CustomNullaryOp is the type of the functor. - * - * \sa class CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Constant(const Scalar& value) -{ - IMP_EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return DenseBase::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_constant_op(value)); -} - -/** - * \brief Sets a linearly space vector. - * - * The function generates 'size' equally spaced values in the closed interval [low,high]. - * This particular version of LinSpaced() uses sequential access, i.e. vector access is - * assumed to be a(0), a(1), ..., a(size). This assumption allows for better vectorization - * and yields faster code than the random access version. - * - * When size is set to 1, a vector of length 1 containing 'high' is returned. - * - * \only_for_vectors - * - * Example: \include DenseBase_LinSpaced_seq.cpp - * Output: \verbinclude DenseBase_LinSpaced_seq.out - * - * \sa setLinSpaced(Index,const Scalar&,const Scalar&), LinSpaced(Index,Scalar,Scalar), CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::SequentialLinSpacedReturnType -DenseBase::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return DenseBase::NullaryExpr(size, internal::linspaced_op(low,high,size)); -} - -/** - * \copydoc DenseBase::LinSpaced(Sequential_t, Index, const Scalar&, const Scalar&) - * Special version for fixed size types which does not require the size parameter. - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::SequentialLinSpacedReturnType -DenseBase::LinSpaced(Sequential_t, const Scalar& low, const Scalar& high) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - IMP_EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return DenseBase::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op(low,high,Derived::SizeAtCompileTime)); -} - -/** - * \brief Sets a linearly space vector. - * - * The function generates 'size' equally spaced values in the closed interval [low,high]. - * When size is set to 1, a vector of length 1 containing 'high' is returned. - * - * \only_for_vectors - * - * Example: \include DenseBase_LinSpaced.cpp - * Output: \verbinclude DenseBase_LinSpaced.out - * - * \sa setLinSpaced(Index,const Scalar&,const Scalar&), LinSpaced(Sequential_t,Index,const Scalar&,const Scalar&,Index), CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::RandomAccessLinSpacedReturnType -DenseBase::LinSpaced(Index size, const Scalar& low, const Scalar& high) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return DenseBase::NullaryExpr(size, internal::linspaced_op(low,high,size)); -} - -/** - * \copydoc DenseBase::LinSpaced(Index, const Scalar&, const Scalar&) - * Special version for fixed size types which does not require the size parameter. - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::RandomAccessLinSpacedReturnType -DenseBase::LinSpaced(const Scalar& low, const Scalar& high) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - IMP_EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return DenseBase::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op(low,high,Derived::SizeAtCompileTime)); -} - -/** \returns true if all coefficients in this matrix are approximately equal to \a val, to within precision \a prec */ -template -bool DenseBase::isApproxToConstant -(const Scalar& val, const RealScalar& prec) const -{ - for(Index j = 0; j < cols(); ++j) - for(Index i = 0; i < rows(); ++i) - if(!internal::isApprox(this->coeff(i, j), val, prec)) - return false; - return true; -} - -/** This is just an alias for isApproxToConstant(). - * - * \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */ -template -bool DenseBase::isConstant -(const Scalar& val, const RealScalar& prec) const -{ - return isApproxToConstant(val, prec); -} - -/** Alias for setConstant(): sets all coefficients in this expression to \a val. - * - * \sa setConstant(), Constant(), class CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE void DenseBase::fill(const Scalar& val) -{ - setConstant(val); -} - -/** Sets all coefficients in this expression to \a value. - * - * \sa fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase::setConstant(const Scalar& val) -{ - return derived() = Constant(rows(), cols(), val); -} - -/** Resizes to the given \a size, and sets all coefficients in this expression to the given \a value. - * - * \only_for_vectors - * - * Example: \include Matrix_setConstant_int.cpp - * Output: \verbinclude Matrix_setConstant_int.out - * - * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setConstant(Index size, const Scalar& val) -{ - resize(size); - return setConstant(val); -} - -/** Resizes to the given size, and sets all coefficients in this expression to the given \a value. - * - * \param nbRows the new number of rows - * \param nbCols the new number of columns - * \param val the value to which all coefficients are set - * - * Example: \include Matrix_setConstant_int_int.cpp - * Output: \verbinclude Matrix_setConstant_int_int.out - * - * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setConstant(Index nbRows, Index nbCols, const Scalar& val) -{ - resize(nbRows, nbCols); - return setConstant(val); -} - -/** - * \brief Sets a linearly space vector. - * - * The function generates 'size' equally spaced values in the closed interval [low,high]. - * When size is set to 1, a vector of length 1 containing 'high' is returned. - * - * \only_for_vectors - * - * Example: \include DenseBase_setLinSpaced.cpp - * Output: \verbinclude DenseBase_setLinSpaced.out - * - * \sa CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase::setLinSpaced(Index newSize, const Scalar& low, const Scalar& high) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op(low,high,newSize)); -} - -/** - * \brief Sets a linearly space vector. - * - * The function fill *this with equally spaced values in the closed interval [low,high]. - * When size is set to 1, a vector of length 1 containing 'high' is returned. - * - * \only_for_vectors - * - * \sa setLinSpaced(Index, const Scalar&, const Scalar&), CwiseNullaryOp - */ -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase::setLinSpaced(const Scalar& low, const Scalar& high) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return setLinSpaced(size(), low, high); -} - -// zero: - -/** \returns an expression of a zero matrix. - * - * The parameters \a rows and \a cols are the number of rows and of columns of - * the returned matrix. Must be compatible with this MatrixBase type. - * - * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used - * instead. - * - * Example: \include MatrixBase_zero_int_int.cpp - * Output: \verbinclude MatrixBase_zero_int_int.out - * - * \sa Zero(), Zero(Index) - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Zero(Index nbRows, Index nbCols) -{ - return Constant(nbRows, nbCols, Scalar(0)); -} - -/** \returns an expression of a zero vector. - * - * The parameter \a size is the size of the returned vector. - * Must be compatible with this MatrixBase type. - * - * \only_for_vectors - * - * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so Zero() should be used - * instead. - * - * Example: \include MatrixBase_zero_int.cpp - * Output: \verbinclude MatrixBase_zero_int.out - * - * \sa Zero(), Zero(Index,Index) - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Zero(Index size) -{ - return Constant(size, Scalar(0)); -} - -/** \returns an expression of a fixed-size zero matrix or vector. - * - * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you - * need to use the variants taking size arguments. - * - * Example: \include MatrixBase_zero.cpp - * Output: \verbinclude MatrixBase_zero.out - * - * \sa Zero(Index), Zero(Index,Index) - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Zero() -{ - return Constant(Scalar(0)); -} - -/** \returns true if *this is approximately equal to the zero matrix, - * within the precision given by \a prec. - * - * Example: \include MatrixBase_isZero.cpp - * Output: \verbinclude MatrixBase_isZero.out - * - * \sa class CwiseNullaryOp, Zero() - */ -template -bool DenseBase::isZero(const RealScalar& prec) const -{ - for(Index j = 0; j < cols(); ++j) - for(Index i = 0; i < rows(); ++i) - if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast(1), prec)) - return false; - return true; -} - -/** Sets all coefficients in this expression to zero. - * - * Example: \include MatrixBase_setZero.cpp - * Output: \verbinclude MatrixBase_setZero.out - * - * \sa class CwiseNullaryOp, Zero() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase::setZero() -{ - return setConstant(Scalar(0)); -} - -/** Resizes to the given \a size, and sets all coefficients in this expression to zero. - * - * \only_for_vectors - * - * Example: \include Matrix_setZero_int.cpp - * Output: \verbinclude Matrix_setZero_int.out - * - * \sa DenseBase::setZero(), setZero(Index,Index), class CwiseNullaryOp, DenseBase::Zero() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setZero(Index newSize) -{ - resize(newSize); - return setConstant(Scalar(0)); -} - -/** Resizes to the given size, and sets all coefficients in this expression to zero. - * - * \param nbRows the new number of rows - * \param nbCols the new number of columns - * - * Example: \include Matrix_setZero_int_int.cpp - * Output: \verbinclude Matrix_setZero_int_int.out - * - * \sa DenseBase::setZero(), setZero(Index), class CwiseNullaryOp, DenseBase::Zero() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setZero(Index nbRows, Index nbCols) -{ - resize(nbRows, nbCols); - return setConstant(Scalar(0)); -} - -// ones: - -/** \returns an expression of a matrix where all coefficients equal one. - * - * The parameters \a nbRows and \a nbCols are the number of rows and of columns of - * the returned matrix. Must be compatible with this MatrixBase type. - * - * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so Ones() should be used - * instead. - * - * Example: \include MatrixBase_ones_int_int.cpp - * Output: \verbinclude MatrixBase_ones_int_int.out - * - * \sa Ones(), Ones(Index), isOnes(), class Ones - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Ones(Index nbRows, Index nbCols) -{ - return Constant(nbRows, nbCols, Scalar(1)); -} - -/** \returns an expression of a vector where all coefficients equal one. - * - * The parameter \a newSize is the size of the returned vector. - * Must be compatible with this MatrixBase type. - * - * \only_for_vectors - * - * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so Ones() should be used - * instead. - * - * Example: \include MatrixBase_ones_int.cpp - * Output: \verbinclude MatrixBase_ones_int.out - * - * \sa Ones(), Ones(Index,Index), isOnes(), class Ones - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Ones(Index newSize) -{ - return Constant(newSize, Scalar(1)); -} - -/** \returns an expression of a fixed-size matrix or vector where all coefficients equal one. - * - * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you - * need to use the variants taking size arguments. - * - * Example: \include MatrixBase_ones.cpp - * Output: \verbinclude MatrixBase_ones.out - * - * \sa Ones(Index), Ones(Index,Index), isOnes(), class Ones - */ -template -IMP_EIGEN_STRONG_INLINE const typename DenseBase::ConstantReturnType -DenseBase::Ones() -{ - return Constant(Scalar(1)); -} - -/** \returns true if *this is approximately equal to the matrix where all coefficients - * are equal to 1, within the precision given by \a prec. - * - * Example: \include MatrixBase_isOnes.cpp - * Output: \verbinclude MatrixBase_isOnes.out - * - * \sa class CwiseNullaryOp, Ones() - */ -template -bool DenseBase::isOnes -(const RealScalar& prec) const -{ - return isApproxToConstant(Scalar(1), prec); -} - -/** Sets all coefficients in this expression to one. - * - * Example: \include MatrixBase_setOnes.cpp - * Output: \verbinclude MatrixBase_setOnes.out - * - * \sa class CwiseNullaryOp, Ones() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& DenseBase::setOnes() -{ - return setConstant(Scalar(1)); -} - -/** Resizes to the given \a newSize, and sets all coefficients in this expression to one. - * - * \only_for_vectors - * - * Example: \include Matrix_setOnes_int.cpp - * Output: \verbinclude Matrix_setOnes_int.out - * - * \sa MatrixBase::setOnes(), setOnes(Index,Index), class CwiseNullaryOp, MatrixBase::Ones() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setOnes(Index newSize) -{ - resize(newSize); - return setConstant(Scalar(1)); -} - -/** Resizes to the given size, and sets all coefficients in this expression to one. - * - * \param nbRows the new number of rows - * \param nbCols the new number of columns - * - * Example: \include Matrix_setOnes_int_int.cpp - * Output: \verbinclude Matrix_setOnes_int_int.out - * - * \sa MatrixBase::setOnes(), setOnes(Index), class CwiseNullaryOp, MatrixBase::Ones() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setOnes(Index nbRows, Index nbCols) -{ - resize(nbRows, nbCols); - return setConstant(Scalar(1)); -} - -// Identity: - -/** \returns an expression of the identity matrix (not necessarily square). - * - * The parameters \a nbRows and \a nbCols are the number of rows and of columns of - * the returned matrix. Must be compatible with this MatrixBase type. - * - * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so Identity() should be used - * instead. - * - * Example: \include MatrixBase_identity_int_int.cpp - * Output: \verbinclude MatrixBase_identity_int_int.out - * - * \sa Identity(), setIdentity(), isIdentity() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::IdentityReturnType -MatrixBase::Identity(Index nbRows, Index nbCols) -{ - return DenseBase::NullaryExpr(nbRows, nbCols, internal::scalar_identity_op()); -} - -/** \returns an expression of the identity matrix (not necessarily square). - * - * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you - * need to use the variant taking size arguments. - * - * Example: \include MatrixBase_identity.cpp - * Output: \verbinclude MatrixBase_identity.out - * - * \sa Identity(Index,Index), setIdentity(), isIdentity() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::IdentityReturnType -MatrixBase::Identity() -{ - IMP_EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - return MatrixBase::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op()); -} - -/** \returns true if *this is approximately equal to the identity matrix - * (not necessarily square), - * within the precision given by \a prec. - * - * Example: \include MatrixBase_isIdentity.cpp - * Output: \verbinclude MatrixBase_isIdentity.out - * - * \sa class CwiseNullaryOp, Identity(), Identity(Index,Index), setIdentity() - */ -template -bool MatrixBase::isIdentity -(const RealScalar& prec) const -{ - for(Index j = 0; j < cols(); ++j) - { - for(Index i = 0; i < rows(); ++i) - { - if(i == j) - { - if(!internal::isApprox(this->coeff(i, j), static_cast(1), prec)) - return false; - } - else - { - if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast(1), prec)) - return false; - } - } - } - return true; -} - -namespace internal { - -template=16)> -struct setIdentity_impl -{ - static IMP_EIGEN_STRONG_INLINE Derived& run(Derived& m) - { - return m = Derived::Identity(m.rows(), m.cols()); - } -}; - -template -struct setIdentity_impl -{ - typedef typename Derived::Index Index; - static IMP_EIGEN_STRONG_INLINE Derived& run(Derived& m) - { - m.setZero(); - const Index size = (std::min)(m.rows(), m.cols()); - for(Index i = 0; i < size; ++i) m.coeffRef(i,i) = typename Derived::Scalar(1); - return m; - } -}; - -} // end namespace internal - -/** Writes the identity expression (not necessarily square) into *this. - * - * Example: \include MatrixBase_setIdentity.cpp - * Output: \verbinclude MatrixBase_setIdentity.out - * - * \sa class CwiseNullaryOp, Identity(), Identity(Index,Index), isIdentity() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& MatrixBase::setIdentity() -{ - return internal::setIdentity_impl::run(derived()); -} - -/** \brief Resizes to the given size, and writes the identity expression (not necessarily square) into *this. - * - * \param nbRows the new number of rows - * \param nbCols the new number of columns - * - * Example: \include Matrix_setIdentity_int_int.cpp - * Output: \verbinclude Matrix_setIdentity_int_int.out - * - * \sa MatrixBase::setIdentity(), class CwiseNullaryOp, MatrixBase::Identity() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& MatrixBase::setIdentity(Index nbRows, Index nbCols) -{ - derived().resize(nbRows, nbCols); - return setIdentity(); -} - -/** \returns an expression of the i-th unit (basis) vector. - * - * \only_for_vectors - * - * \sa MatrixBase::Unit(Index), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::BasisReturnType MatrixBase::Unit(Index newSize, Index i) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return BasisReturnType(SquareMatrixType::Identity(newSize,newSize), i); -} - -/** \returns an expression of the i-th unit (basis) vector. - * - * \only_for_vectors - * - * This variant is for fixed-size vector only. - * - * \sa MatrixBase::Unit(Index,Index), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::BasisReturnType MatrixBase::Unit(Index i) -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - return BasisReturnType(SquareMatrixType::Identity(),i); -} - -/** \returns an expression of the X axis unit vector (1{,0}^*) - * - * \only_for_vectors - * - * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::BasisReturnType MatrixBase::UnitX() -{ return Derived::Unit(0); } - -/** \returns an expression of the Y axis unit vector (0,1{,0}^*) - * - * \only_for_vectors - * - * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::BasisReturnType MatrixBase::UnitY() -{ return Derived::Unit(1); } - -/** \returns an expression of the Z axis unit vector (0,0,1{,0}^*) - * - * \only_for_vectors - * - * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::BasisReturnType MatrixBase::UnitZ() -{ return Derived::Unit(2); } - -/** \returns an expression of the W axis unit vector (0,0,0,1) - * - * \only_for_vectors - * - * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW() - */ -template -IMP_EIGEN_STRONG_INLINE const typename MatrixBase::BasisReturnType MatrixBase::UnitW() -{ return Derived::Unit(3); } - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_CWISE_NULLARY_OP_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryOp.h b/modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryOp.h deleted file mode 100644 index 4262e5bf1f..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryOp.h +++ /dev/null @@ -1,126 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2010 Gael Guennebaud -// Copyright (C) 2006-2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_CWISE_UNARY_OP_H -#define IMP_EIGEN_CWISE_UNARY_OP_H - -namespace IMP_Eigen { - -/** \class CwiseUnaryOp - * \ingroup Core_Module - * - * \brief Generic expression where a coefficient-wise unary operator is applied to an expression - * - * \param UnaryOp template functor implementing the operator - * \param XprType the type of the expression to which we are applying the unary operator - * - * This class represents an expression where a unary operator is applied to an expression. - * It is the return type of all operations taking exactly 1 input expression, regardless of the - * presence of other inputs such as scalars. For example, the operator* in the expression 3*matrix - * is considered unary, because only the right-hand side is an expression, and its - * return type is a specialization of CwiseUnaryOp. - * - * Most of the time, this is the only way that it is used, so you typically don't have to name - * CwiseUnaryOp types explicitly. - * - * \sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp - */ - -namespace internal { -template -struct traits > - : traits -{ - typedef typename result_of< - UnaryOp(typename XprType::Scalar) - >::type Scalar; - typedef typename XprType::Nested XprTypeNested; - typedef typename remove_reference::type _XprTypeNested; - enum { - Flags = _XprTypeNested::Flags & ( - HereditaryBits | LinearAccessBit | AlignedBit - | (functor_traits::PacketAccess ? PacketAccessBit : 0)), - CoeffReadCost = IMP_EIGEN_ADD_COST(_XprTypeNested::CoeffReadCost, functor_traits::Cost) - }; -}; -} - -template -class CwiseUnaryOpImpl; - -template -class CwiseUnaryOp : internal::no_assignment_operator, - public CwiseUnaryOpImpl::StorageKind> -{ - public: - - typedef typename CwiseUnaryOpImpl::StorageKind>::Base Base; - IMP_EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp) - - inline CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp()) - : m_xpr(xpr), m_functor(func) {} - - IMP_EIGEN_STRONG_INLINE Index rows() const { return m_xpr.rows(); } - IMP_EIGEN_STRONG_INLINE Index cols() const { return m_xpr.cols(); } - - /** \returns the functor representing the unary operation */ - const UnaryOp& functor() const { return m_functor; } - - /** \returns the nested expression */ - const typename internal::remove_all::type& - nestedExpression() const { return m_xpr; } - - /** \returns the nested expression */ - typename internal::remove_all::type& - nestedExpression() { return m_xpr.const_cast_derived(); } - - protected: - typename XprType::Nested m_xpr; - const UnaryOp m_functor; -}; - -// This is the generic implementation for dense storage. -// It can be used for any expression types implementing the dense concept. -template -class CwiseUnaryOpImpl - : public internal::dense_xpr_base >::type -{ - public: - - typedef CwiseUnaryOp Derived; - typedef typename internal::dense_xpr_base >::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Derived) - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index rowId, Index colId) const - { - return derived().functor()(derived().nestedExpression().coeff(rowId, colId)); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const - { - return derived().functor().packetOp(derived().nestedExpression().template packet(rowId, colId)); - } - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index index) const - { - return derived().functor()(derived().nestedExpression().coeff(index)); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index index) const - { - return derived().functor().packetOp(derived().nestedExpression().template packet(index)); - } -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_CWISE_UNARY_OP_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryView.h b/modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryView.h deleted file mode 100644 index 2b21f9557c..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/CwiseUnaryView.h +++ /dev/null @@ -1,139 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_CWISE_UNARY_VIEW_H -#define IMP_EIGEN_CWISE_UNARY_VIEW_H - -namespace IMP_Eigen { - -/** \class CwiseUnaryView - * \ingroup Core_Module - * - * \brief Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector - * - * \param ViewOp template functor implementing the view - * \param MatrixType the type of the matrix we are applying the unary operator - * - * This class represents a lvalue expression of a generic unary view operator of a matrix or a vector. - * It is the return type of real() and imag(), and most of the time this is the only way it is used. - * - * \sa MatrixBase::unaryViewExpr(const CustomUnaryOp &) const, class CwiseUnaryOp - */ - -namespace internal { -template -struct traits > - : traits -{ - typedef typename result_of< - ViewOp(typename traits::Scalar) - >::type Scalar; - typedef typename MatrixType::Nested MatrixTypeNested; - typedef typename remove_all::type _MatrixTypeNested; - enum { - Flags = (traits<_MatrixTypeNested>::Flags & (HereditaryBits | LvalueBit | LinearAccessBit | DirectAccessBit)), - CoeffReadCost = IMP_EIGEN_ADD_COST(traits<_MatrixTypeNested>::CoeffReadCost, functor_traits::Cost), - MatrixTypeInnerStride = inner_stride_at_compile_time::ret, - // need to cast the sizeof's from size_t to int explicitly, otherwise: - // "error: no integral type can represent all of the enumerator values - InnerStrideAtCompileTime = MatrixTypeInnerStride == Dynamic - ? int(Dynamic) - : int(MatrixTypeInnerStride) * int(sizeof(typename traits::Scalar) / sizeof(Scalar)), - OuterStrideAtCompileTime = outer_stride_at_compile_time::ret == Dynamic - ? int(Dynamic) - : outer_stride_at_compile_time::ret * int(sizeof(typename traits::Scalar) / sizeof(Scalar)) - }; -}; -} - -template -class CwiseUnaryViewImpl; - -template -class CwiseUnaryView : public CwiseUnaryViewImpl::StorageKind> -{ - public: - - typedef typename CwiseUnaryViewImpl::StorageKind>::Base Base; - IMP_EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView) - - inline CwiseUnaryView(const MatrixType& mat, const ViewOp& func = ViewOp()) - : m_matrix(mat), m_functor(func) {} - - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView) - - IMP_EIGEN_STRONG_INLINE Index rows() const { return m_matrix.rows(); } - IMP_EIGEN_STRONG_INLINE Index cols() const { return m_matrix.cols(); } - - /** \returns the functor representing unary operation */ - const ViewOp& functor() const { return m_functor; } - - /** \returns the nested expression */ - const typename internal::remove_all::type& - nestedExpression() const { return m_matrix; } - - /** \returns the nested expression */ - typename internal::remove_all::type& - nestedExpression() { return m_matrix.const_cast_derived(); } - - protected: - // FIXME changed from MatrixType::Nested because of a weird compilation error with sun CC - typename internal::nested::type m_matrix; - ViewOp m_functor; -}; - -template -class CwiseUnaryViewImpl - : public internal::dense_xpr_base< CwiseUnaryView >::type -{ - public: - - typedef CwiseUnaryView Derived; - typedef typename internal::dense_xpr_base< CwiseUnaryView >::type Base; - - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Derived) - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl) - - inline Scalar* data() { return &coeffRef(0); } - inline const Scalar* data() const { return &coeff(0); } - - inline Index innerStride() const - { - return derived().nestedExpression().innerStride() * sizeof(typename internal::traits::Scalar) / sizeof(Scalar); - } - - inline Index outerStride() const - { - return derived().nestedExpression().outerStride() * sizeof(typename internal::traits::Scalar) / sizeof(Scalar); - } - - IMP_EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const - { - return derived().functor()(derived().nestedExpression().coeff(row, col)); - } - - IMP_EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const - { - return derived().functor()(derived().nestedExpression().coeff(index)); - } - - IMP_EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) - { - return derived().functor()(const_cast_derived().nestedExpression().coeffRef(row, col)); - } - - IMP_EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) - { - return derived().functor()(const_cast_derived().nestedExpression().coeffRef(index)); - } -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_CWISE_UNARY_VIEW_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/DenseBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/DenseBase.h deleted file mode 100644 index 9705d4c75a..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/DenseBase.h +++ /dev/null @@ -1,521 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2007-2010 Benoit Jacob -// Copyright (C) 2008-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_DENSEBASE_H -#define IMP_EIGEN_DENSEBASE_H - -namespace IMP_Eigen { - -namespace internal { - -// The index type defined by IMP_EIGEN_DEFAULT_DENSE_INDEX_TYPE must be a signed type. -// This dummy function simply aims at checking that at compile time. -static inline void check_DenseIndex_is_signed() { - IMP_EIGEN_STATIC_ASSERT(NumTraits::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); -} - -} // end namespace internal - -/** \class DenseBase - * \ingroup Core_Module - * - * \brief Base class for all dense matrices, vectors, and arrays - * - * This class is the base that is inherited by all dense objects (matrix, vector, arrays, - * and related expression types). The common Eigen API for dense objects is contained in this class. - * - * \tparam Derived is the derived type, e.g., a matrix type or an expression. - * - * This class can be extended with the help of the plugin mechanism described on the page - * \ref TopicCustomizingEigen by defining the preprocessor symbol \c IMP_EIGEN_DENSEBASE_PLUGIN. - * - * \sa \ref TopicClassHierarchy - */ -template class DenseBase -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - : public internal::special_scalar_op_base::Scalar, - typename NumTraits::Scalar>::Real, - DenseCoeffsBase > -#else - : public DenseCoeffsBase -#endif // not IMP_EIGEN_PARSED_BY_DOXYGEN -{ - public: - - class InnerIterator; - - typedef typename internal::traits::StorageKind StorageKind; - - /** \brief The type of indices - * \details To change this, \c \#define the preprocessor symbol \c IMP_EIGEN_DEFAULT_DENSE_INDEX_TYPE. - * \sa \ref TopicPreprocessorDirectives. - */ - typedef typename internal::traits::Index Index; - - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::packet_traits::type PacketScalar; - typedef typename NumTraits::Real RealScalar; - typedef internal::special_scalar_op_base > Base; - - using Base::operator*; - using Base::derived; - using Base::const_cast_derived; - using Base::rows; - using Base::cols; - using Base::size; - using Base::rowIndexByOuterInner; - using Base::colIndexByOuterInner; - using Base::coeff; - using Base::coeffByOuterInner; - using Base::packet; - using Base::packetByOuterInner; - using Base::writePacket; - using Base::writePacketByOuterInner; - using Base::coeffRef; - using Base::coeffRefByOuterInner; - using Base::copyCoeff; - using Base::copyCoeffByOuterInner; - using Base::copyPacket; - using Base::copyPacketByOuterInner; - using Base::operator(); - using Base::operator[]; - using Base::x; - using Base::y; - using Base::z; - using Base::w; - using Base::stride; - using Base::innerStride; - using Base::outerStride; - using Base::rowStride; - using Base::colStride; - typedef typename Base::CoeffReturnType CoeffReturnType; - - enum { - - RowsAtCompileTime = internal::traits::RowsAtCompileTime, - /**< The number of rows at compile-time. This is just a copy of the value provided - * by the \a Derived type. If a value is not known at compile-time, - * it is set to the \a Dynamic constant. - * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */ - - ColsAtCompileTime = internal::traits::ColsAtCompileTime, - /**< The number of columns at compile-time. This is just a copy of the value provided - * by the \a Derived type. If a value is not known at compile-time, - * it is set to the \a Dynamic constant. - * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */ - - - SizeAtCompileTime = (internal::size_at_compile_time::RowsAtCompileTime, - internal::traits::ColsAtCompileTime>::ret), - /**< This is equal to the number of coefficients, i.e. the number of - * rows times the number of columns, or to \a Dynamic if this is not - * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */ - - MaxRowsAtCompileTime = internal::traits::MaxRowsAtCompileTime, - /**< This value is equal to the maximum possible number of rows that this expression - * might have. If this expression might have an arbitrarily high number of rows, - * this value is set to \a Dynamic. - * - * This value is useful to know when evaluating an expression, in order to determine - * whether it is possible to avoid doing a dynamic memory allocation. - * - * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime - */ - - MaxColsAtCompileTime = internal::traits::MaxColsAtCompileTime, - /**< This value is equal to the maximum possible number of columns that this expression - * might have. If this expression might have an arbitrarily high number of columns, - * this value is set to \a Dynamic. - * - * This value is useful to know when evaluating an expression, in order to determine - * whether it is possible to avoid doing a dynamic memory allocation. - * - * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime - */ - - MaxSizeAtCompileTime = (internal::size_at_compile_time::MaxRowsAtCompileTime, - internal::traits::MaxColsAtCompileTime>::ret), - /**< This value is equal to the maximum possible number of coefficients that this expression - * might have. If this expression might have an arbitrarily high number of coefficients, - * this value is set to \a Dynamic. - * - * This value is useful to know when evaluating an expression, in order to determine - * whether it is possible to avoid doing a dynamic memory allocation. - * - * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime - */ - - IsVectorAtCompileTime = internal::traits::MaxRowsAtCompileTime == 1 - || internal::traits::MaxColsAtCompileTime == 1, - /**< This is set to true if either the number of rows or the number of - * columns is known at compile-time to be equal to 1. Indeed, in that case, - * we are dealing with a column-vector (if there is only one column) or with - * a row-vector (if there is only one row). */ - - Flags = internal::traits::Flags, - /**< This stores expression \ref flags flags which may or may not be inherited by new expressions - * constructed from this one. See the \ref flags "list of flags". - */ - - IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression has row-major storage order. */ - - InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime) - : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime), - - CoeffReadCost = internal::traits::CoeffReadCost, - /**< This is a rough measure of how expensive it is to read one coefficient from - * this expression. - */ - - InnerStrideAtCompileTime = internal::inner_stride_at_compile_time::ret, - OuterStrideAtCompileTime = internal::outer_stride_at_compile_time::ret - }; - - enum { ThisConstantIsPrivateInPlainObjectBase }; - - /** \returns the number of nonzero coefficients which is in practice the number - * of stored coefficients. */ - inline Index nonZeros() const { return size(); } - - /** \returns the outer size. - * - * \note For a vector, this returns just 1. For a matrix (non-vector), this is the major dimension - * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of columns for a - * column-major matrix, and the number of rows for a row-major matrix. */ - Index outerSize() const - { - return IsVectorAtCompileTime ? 1 - : int(IsRowMajor) ? this->rows() : this->cols(); - } - - /** \returns the inner size. - * - * \note For a vector, this is just the size. For a matrix (non-vector), this is the minor dimension - * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of rows for a - * column-major matrix, and the number of columns for a row-major matrix. */ - Index innerSize() const - { - return IsVectorAtCompileTime ? this->size() - : int(IsRowMajor) ? this->cols() : this->rows(); - } - - /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are - * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does - * nothing else. - */ - void resize(Index newSize) - { - IMP_EIGEN_ONLY_USED_FOR_DEBUG(newSize); - imp_eigen_assert(newSize == this->size() - && "DenseBase::resize() does not actually allow to resize."); - } - /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are - * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does - * nothing else. - */ - void resize(Index nbRows, Index nbCols) - { - IMP_EIGEN_ONLY_USED_FOR_DEBUG(nbRows); - IMP_EIGEN_ONLY_USED_FOR_DEBUG(nbCols); - imp_eigen_assert(nbRows == this->rows() && nbCols == this->cols() - && "DenseBase::resize() does not actually allow to resize."); - } - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - - /** \internal Represents a matrix with all coefficients equal to one another*/ - typedef CwiseNullaryOp,Derived> ConstantReturnType; - /** \internal Represents a vector with linearly spaced coefficients that allows sequential access only. */ - typedef CwiseNullaryOp,Derived> SequentialLinSpacedReturnType; - /** \internal Represents a vector with linearly spaced coefficients that allows random access. */ - typedef CwiseNullaryOp,Derived> RandomAccessLinSpacedReturnType; - /** \internal the return type of MatrixBase::eigenvalues() */ - typedef Matrix::Scalar>::Real, internal::traits::ColsAtCompileTime, 1> EigenvaluesReturnType; - -#endif // not IMP_EIGEN_PARSED_BY_DOXYGEN - - /** Copies \a other into *this. \returns a reference to *this. */ - template - Derived& operator=(const DenseBase& other); - - /** Special case of the template operator=, in order to prevent the compiler - * from generating a default operator= (issue hit with g++ 4.1) - */ - Derived& operator=(const DenseBase& other); - - template - Derived& operator=(const EigenBase &other); - - template - Derived& operator+=(const EigenBase &other); - - template - Derived& operator-=(const EigenBase &other); - - template - Derived& operator=(const ReturnByValue& func); - - /** \internal Copies \a other into *this without evaluating other. \returns a reference to *this. */ - template - Derived& lazyAssign(const DenseBase& other); - - /** \internal Evaluates \a other into *this. \returns a reference to *this. */ - template - Derived& lazyAssign(const ReturnByValue& other); - - CommaInitializer operator<< (const Scalar& s); - - template - const Flagged flagged() const; - - template - CommaInitializer operator<< (const DenseBase& other); - - IMP_Eigen::Transpose transpose(); - typedef typename internal::add_const >::type ConstTransposeReturnType; - ConstTransposeReturnType transpose() const; - void transposeInPlace(); -#ifndef IMP_EIGEN_NO_DEBUG - protected: - template - void checkTransposeAliasing(const OtherDerived& other) const; - public: -#endif - - - static const ConstantReturnType - Constant(Index rows, Index cols, const Scalar& value); - static const ConstantReturnType - Constant(Index size, const Scalar& value); - static const ConstantReturnType - Constant(const Scalar& value); - - static const SequentialLinSpacedReturnType - LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high); - static const RandomAccessLinSpacedReturnType - LinSpaced(Index size, const Scalar& low, const Scalar& high); - static const SequentialLinSpacedReturnType - LinSpaced(Sequential_t, const Scalar& low, const Scalar& high); - static const RandomAccessLinSpacedReturnType - LinSpaced(const Scalar& low, const Scalar& high); - - template - static const CwiseNullaryOp - NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func); - template - static const CwiseNullaryOp - NullaryExpr(Index size, const CustomNullaryOp& func); - template - static const CwiseNullaryOp - NullaryExpr(const CustomNullaryOp& func); - - static const ConstantReturnType Zero(Index rows, Index cols); - static const ConstantReturnType Zero(Index size); - static const ConstantReturnType Zero(); - static const ConstantReturnType Ones(Index rows, Index cols); - static const ConstantReturnType Ones(Index size); - static const ConstantReturnType Ones(); - - void fill(const Scalar& value); - Derived& setConstant(const Scalar& value); - Derived& setLinSpaced(Index size, const Scalar& low, const Scalar& high); - Derived& setLinSpaced(const Scalar& low, const Scalar& high); - Derived& setZero(); - Derived& setOnes(); - Derived& setRandom(); - - template - bool isApprox(const DenseBase& other, - const RealScalar& prec = NumTraits::dummy_precision()) const; - bool isMuchSmallerThan(const RealScalar& other, - const RealScalar& prec = NumTraits::dummy_precision()) const; - template - bool isMuchSmallerThan(const DenseBase& other, - const RealScalar& prec = NumTraits::dummy_precision()) const; - - bool isApproxToConstant(const Scalar& value, const RealScalar& prec = NumTraits::dummy_precision()) const; - bool isConstant(const Scalar& value, const RealScalar& prec = NumTraits::dummy_precision()) const; - bool isZero(const RealScalar& prec = NumTraits::dummy_precision()) const; - bool isOnes(const RealScalar& prec = NumTraits::dummy_precision()) const; - - inline bool hasNaN() const; - inline bool allFinite() const; - - inline Derived& operator*=(const Scalar& other); - inline Derived& operator/=(const Scalar& other); - - typedef typename internal::add_const_on_value_type::type>::type EvalReturnType; - /** \returns the matrix or vector obtained by evaluating this expression. - * - * Notice that in the case of a plain matrix or vector (not an expression) this function just returns - * a const reference, in order to avoid a useless copy. - */ - IMP_EIGEN_STRONG_INLINE EvalReturnType eval() const - { - // Even though MSVC does not honor strong inlining when the return type - // is a dynamic matrix, we desperately need strong inlining for fixed - // size types on MSVC. - return typename internal::eval::type(derived()); - } - - /** swaps *this with the expression \a other. - * - */ - template - void swap(const DenseBase& other, - int = OtherDerived::ThisConstantIsPrivateInPlainObjectBase) - { - SwapWrapper(derived()).lazyAssign(other.derived()); - } - - /** swaps *this with the matrix or array \a other. - * - */ - template - void swap(PlainObjectBase& other) - { - SwapWrapper(derived()).lazyAssign(other.derived()); - } - - - inline const NestByValue nestByValue() const; - inline const ForceAlignedAccess forceAlignedAccess() const; - inline ForceAlignedAccess forceAlignedAccess(); - template inline const typename internal::conditional,Derived&>::type forceAlignedAccessIf() const; - template inline typename internal::conditional,Derived&>::type forceAlignedAccessIf(); - - Scalar sum() const; - Scalar mean() const; - Scalar trace() const; - - Scalar prod() const; - - typename internal::traits::Scalar minCoeff() const; - typename internal::traits::Scalar maxCoeff() const; - - template - typename internal::traits::Scalar minCoeff(IndexType* row, IndexType* col) const; - template - typename internal::traits::Scalar maxCoeff(IndexType* row, IndexType* col) const; - template - typename internal::traits::Scalar minCoeff(IndexType* index) const; - template - typename internal::traits::Scalar maxCoeff(IndexType* index) const; - - template - typename internal::result_of::Scalar)>::type - redux(const BinaryOp& func) const; - - template - void visit(Visitor& func) const; - - inline const WithFormat format(const IOFormat& fmt) const; - - /** \returns the unique coefficient of a 1x1 expression */ - CoeffReturnType value() const - { - IMP_EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) - imp_eigen_assert(this->rows() == 1 && this->cols() == 1); - return derived().coeff(0,0); - } - - bool all(void) const; - bool any(void) const; - Index count() const; - - typedef VectorwiseOp RowwiseReturnType; - typedef const VectorwiseOp ConstRowwiseReturnType; - typedef VectorwiseOp ColwiseReturnType; - typedef const VectorwiseOp ConstColwiseReturnType; - - ConstRowwiseReturnType rowwise() const; - RowwiseReturnType rowwise(); - ConstColwiseReturnType colwise() const; - ColwiseReturnType colwise(); - - static const CwiseNullaryOp,Derived> Random(Index rows, Index cols); - static const CwiseNullaryOp,Derived> Random(Index size); - static const CwiseNullaryOp,Derived> Random(); - - template - const Select - select(const DenseBase& thenMatrix, - const DenseBase& elseMatrix) const; - - template - inline const Select - select(const DenseBase& thenMatrix, const typename ThenDerived::Scalar& elseScalar) const; - - template - inline const Select - select(const typename ElseDerived::Scalar& thenScalar, const DenseBase& elseMatrix) const; - - template RealScalar lpNorm() const; - - template - inline const Replicate replicate() const; - - typedef Replicate ReplicateReturnType; - inline const ReplicateReturnType replicate(Index rowFacor,Index colFactor) const; - - typedef Reverse ReverseReturnType; - typedef const Reverse ConstReverseReturnType; - ReverseReturnType reverse(); - ConstReverseReturnType reverse() const; - void reverseInPlace(); - -#define IMP_EIGEN_CURRENT_STORAGE_BASE_CLASS IMP_Eigen::DenseBase -# include "../plugins/BlockMethods.h" -# ifdef IMP_EIGEN_DENSEBASE_PLUGIN -# include IMP_EIGEN_DENSEBASE_PLUGIN -# endif -#undef IMP_EIGEN_CURRENT_STORAGE_BASE_CLASS - -#ifdef IMP_EIGEN2_SUPPORT - - Block corner(CornerType type, Index cRows, Index cCols); - const Block corner(CornerType type, Index cRows, Index cCols) const; - template - Block corner(CornerType type); - template - const Block corner(CornerType type) const; - -#endif // IMP_EIGEN2_SUPPORT - - - // disable the use of evalTo for dense objects with a nice compilation error - template inline void evalTo(Dest& ) const - { - IMP_EIGEN_STATIC_ASSERT((internal::is_same::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS); - } - - protected: - /** Default constructor. Do nothing. */ - DenseBase() - { - /* Just checks for self-consistency of the flags. - * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down - */ -#ifdef IMP_EIGEN_INTERNAL_DEBUGGING - IMP_EIGEN_STATIC_ASSERT((IMP_EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, int(IsRowMajor)) - && IMP_EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, int(!IsRowMajor))), - INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION) -#endif - } - - private: - explicit DenseBase(int); - DenseBase(int,int); - template explicit DenseBase(const DenseBase&); -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_DENSEBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h deleted file mode 100644 index 1c874ccea8..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h +++ /dev/null @@ -1,754 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2010 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_DENSECOEFFSBASE_H -#define IMP_EIGEN_DENSECOEFFSBASE_H - -namespace IMP_Eigen { - -namespace internal { -template struct add_const_on_value_type_if_arithmetic -{ - typedef typename conditional::value, T, typename add_const_on_value_type::type>::type type; -}; -} - -/** \brief Base class providing read-only coefficient access to matrices and arrays. - * \ingroup Core_Module - * \tparam Derived Type of the derived class - * \tparam #ReadOnlyAccessors Constant indicating read-only access - * - * This class defines the \c operator() \c const function and friends, which can be used to read specific - * entries of a matrix or array. - * - * \sa DenseCoeffsBase, DenseCoeffsBase, - * \ref TopicClassHierarchy - */ -template -class DenseCoeffsBase : public EigenBase -{ - public: - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::packet_traits::type PacketScalar; - - // Explanation for this CoeffReturnType typedef. - // - This is the return type of the coeff() method. - // - The LvalueBit means exactly that we can offer a coeffRef() method, which means exactly that we can get references - // to coeffs, which means exactly that we can have coeff() return a const reference (as opposed to returning a value). - // - The is_artihmetic check is required since "const int", "const double", etc. will cause warnings on some systems - // while the declaration of "const T", where T is a non arithmetic type does not. Always returning "const Scalar&" is - // not possible, since the underlying expressions might not offer a valid address the reference could be referring to. - typedef typename internal::conditional::Flags&LvalueBit), - const Scalar&, - typename internal::conditional::value, Scalar, const Scalar>::type - >::type CoeffReturnType; - - typedef typename internal::add_const_on_value_type_if_arithmetic< - typename internal::packet_traits::type - >::type PacketReturnType; - - typedef EigenBase Base; - using Base::rows; - using Base::cols; - using Base::size; - using Base::derived; - - IMP_EIGEN_STRONG_INLINE Index rowIndexByOuterInner(Index outer, Index inner) const - { - return int(Derived::RowsAtCompileTime) == 1 ? 0 - : int(Derived::ColsAtCompileTime) == 1 ? inner - : int(Derived::Flags)&RowMajorBit ? outer - : inner; - } - - IMP_EIGEN_STRONG_INLINE Index colIndexByOuterInner(Index outer, Index inner) const - { - return int(Derived::ColsAtCompileTime) == 1 ? 0 - : int(Derived::RowsAtCompileTime) == 1 ? inner - : int(Derived::Flags)&RowMajorBit ? inner - : outer; - } - - /** Short version: don't use this function, use - * \link operator()(Index,Index) const \endlink instead. - * - * Long version: this function is similar to - * \link operator()(Index,Index) const \endlink, but without the assertion. - * Use this for limiting the performance cost of debugging code when doing - * repeated coefficient access. Only use this when it is guaranteed that the - * parameters \a row and \a col are in range. - * - * If IMP_EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this - * function equivalent to \link operator()(Index,Index) const \endlink. - * - * \sa operator()(Index,Index) const, coeffRef(Index,Index), coeff(Index) const - */ - IMP_EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const - { - imp_eigen_internal_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - return derived().coeff(row, col); - } - - IMP_EIGEN_STRONG_INLINE CoeffReturnType coeffByOuterInner(Index outer, Index inner) const - { - return coeff(rowIndexByOuterInner(outer, inner), - colIndexByOuterInner(outer, inner)); - } - - /** \returns the coefficient at given the given row and column. - * - * \sa operator()(Index,Index), operator[](Index) - */ - IMP_EIGEN_STRONG_INLINE CoeffReturnType operator()(Index row, Index col) const - { - imp_eigen_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - return derived().coeff(row, col); - } - - /** Short version: don't use this function, use - * \link operator[](Index) const \endlink instead. - * - * Long version: this function is similar to - * \link operator[](Index) const \endlink, but without the assertion. - * Use this for limiting the performance cost of debugging code when doing - * repeated coefficient access. Only use this when it is guaranteed that the - * parameter \a index is in range. - * - * If IMP_EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this - * function equivalent to \link operator[](Index) const \endlink. - * - * \sa operator[](Index) const, coeffRef(Index), coeff(Index,Index) const - */ - - IMP_EIGEN_STRONG_INLINE CoeffReturnType - coeff(Index index) const - { - imp_eigen_internal_assert(index >= 0 && index < size()); - return derived().coeff(index); - } - - - /** \returns the coefficient at given index. - * - * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit. - * - * \sa operator[](Index), operator()(Index,Index) const, x() const, y() const, - * z() const, w() const - */ - - IMP_EIGEN_STRONG_INLINE CoeffReturnType - operator[](Index index) const - { - #ifndef IMP_EIGEN2_SUPPORT - IMP_EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime, - THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD) - #endif - imp_eigen_assert(index >= 0 && index < size()); - return derived().coeff(index); - } - - /** \returns the coefficient at given index. - * - * This is synonymous to operator[](Index) const. - * - * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit. - * - * \sa operator[](Index), operator()(Index,Index) const, x() const, y() const, - * z() const, w() const - */ - - IMP_EIGEN_STRONG_INLINE CoeffReturnType - operator()(Index index) const - { - imp_eigen_assert(index >= 0 && index < size()); - return derived().coeff(index); - } - - /** equivalent to operator[](0). */ - - IMP_EIGEN_STRONG_INLINE CoeffReturnType - x() const { return (*this)[0]; } - - /** equivalent to operator[](1). */ - - IMP_EIGEN_STRONG_INLINE CoeffReturnType - y() const { return (*this)[1]; } - - /** equivalent to operator[](2). */ - - IMP_EIGEN_STRONG_INLINE CoeffReturnType - z() const { return (*this)[2]; } - - /** equivalent to operator[](3). */ - - IMP_EIGEN_STRONG_INLINE CoeffReturnType - w() const { return (*this)[3]; } - - /** \internal - * \returns the packet of coefficients starting at the given row and column. It is your responsibility - * to ensure that a packet really starts there. This method is only available on expressions having the - * PacketAccessBit. - * - * The \a LoadMode parameter may have the value \a #Aligned or \a #Unaligned. Its effect is to select - * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets - * starting at an address which is a multiple of the packet size. - */ - - template - IMP_EIGEN_STRONG_INLINE PacketReturnType packet(Index row, Index col) const - { - imp_eigen_internal_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - return derived().template packet(row,col); - } - - - /** \internal */ - template - IMP_EIGEN_STRONG_INLINE PacketReturnType packetByOuterInner(Index outer, Index inner) const - { - return packet(rowIndexByOuterInner(outer, inner), - colIndexByOuterInner(outer, inner)); - } - - /** \internal - * \returns the packet of coefficients starting at the given index. It is your responsibility - * to ensure that a packet really starts there. This method is only available on expressions having the - * PacketAccessBit and the LinearAccessBit. - * - * The \a LoadMode parameter may have the value \a #Aligned or \a #Unaligned. Its effect is to select - * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets - * starting at an address which is a multiple of the packet size. - */ - - template - IMP_EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const - { - imp_eigen_internal_assert(index >= 0 && index < size()); - return derived().template packet(index); - } - - protected: - // explanation: DenseBase is doing "using ..." on the methods from DenseCoeffsBase. - // But some methods are only available in the DirectAccess case. - // So we add dummy methods here with these names, so that "using... " doesn't fail. - // It's not private so that the child class DenseBase can access them, and it's not public - // either since it's an implementation detail, so has to be protected. - void coeffRef(); - void coeffRefByOuterInner(); - void writePacket(); - void writePacketByOuterInner(); - void copyCoeff(); - void copyCoeffByOuterInner(); - void copyPacket(); - void copyPacketByOuterInner(); - void stride(); - void innerStride(); - void outerStride(); - void rowStride(); - void colStride(); -}; - -/** \brief Base class providing read/write coefficient access to matrices and arrays. - * \ingroup Core_Module - * \tparam Derived Type of the derived class - * \tparam #WriteAccessors Constant indicating read/write access - * - * This class defines the non-const \c operator() function and friends, which can be used to write specific - * entries of a matrix or array. This class inherits DenseCoeffsBase which - * defines the const variant for reading specific entries. - * - * \sa DenseCoeffsBase, \ref TopicClassHierarchy - */ -template -class DenseCoeffsBase : public DenseCoeffsBase -{ - public: - - typedef DenseCoeffsBase Base; - - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::packet_traits::type PacketScalar; - typedef typename NumTraits::Real RealScalar; - - using Base::coeff; - using Base::rows; - using Base::cols; - using Base::size; - using Base::derived; - using Base::rowIndexByOuterInner; - using Base::colIndexByOuterInner; - using Base::operator[]; - using Base::operator(); - using Base::x; - using Base::y; - using Base::z; - using Base::w; - - /** Short version: don't use this function, use - * \link operator()(Index,Index) \endlink instead. - * - * Long version: this function is similar to - * \link operator()(Index,Index) \endlink, but without the assertion. - * Use this for limiting the performance cost of debugging code when doing - * repeated coefficient access. Only use this when it is guaranteed that the - * parameters \a row and \a col are in range. - * - * If IMP_EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this - * function equivalent to \link operator()(Index,Index) \endlink. - * - * \sa operator()(Index,Index), coeff(Index, Index) const, coeffRef(Index) - */ - IMP_EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) - { - imp_eigen_internal_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - return derived().coeffRef(row, col); - } - - IMP_EIGEN_STRONG_INLINE Scalar& - coeffRefByOuterInner(Index outer, Index inner) - { - return coeffRef(rowIndexByOuterInner(outer, inner), - colIndexByOuterInner(outer, inner)); - } - - /** \returns a reference to the coefficient at given the given row and column. - * - * \sa operator[](Index) - */ - - IMP_EIGEN_STRONG_INLINE Scalar& - operator()(Index row, Index col) - { - imp_eigen_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - return derived().coeffRef(row, col); - } - - - /** Short version: don't use this function, use - * \link operator[](Index) \endlink instead. - * - * Long version: this function is similar to - * \link operator[](Index) \endlink, but without the assertion. - * Use this for limiting the performance cost of debugging code when doing - * repeated coefficient access. Only use this when it is guaranteed that the - * parameters \a row and \a col are in range. - * - * If IMP_EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this - * function equivalent to \link operator[](Index) \endlink. - * - * \sa operator[](Index), coeff(Index) const, coeffRef(Index,Index) - */ - - IMP_EIGEN_STRONG_INLINE Scalar& - coeffRef(Index index) - { - imp_eigen_internal_assert(index >= 0 && index < size()); - return derived().coeffRef(index); - } - - /** \returns a reference to the coefficient at given index. - * - * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit. - * - * \sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w() - */ - - IMP_EIGEN_STRONG_INLINE Scalar& - operator[](Index index) - { - #ifndef IMP_EIGEN2_SUPPORT - IMP_EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime, - THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD) - #endif - imp_eigen_assert(index >= 0 && index < size()); - return derived().coeffRef(index); - } - - /** \returns a reference to the coefficient at given index. - * - * This is synonymous to operator[](Index). - * - * This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit. - * - * \sa operator[](Index) const, operator()(Index,Index), x(), y(), z(), w() - */ - - IMP_EIGEN_STRONG_INLINE Scalar& - operator()(Index index) - { - imp_eigen_assert(index >= 0 && index < size()); - return derived().coeffRef(index); - } - - /** equivalent to operator[](0). */ - - IMP_EIGEN_STRONG_INLINE Scalar& - x() { return (*this)[0]; } - - /** equivalent to operator[](1). */ - - IMP_EIGEN_STRONG_INLINE Scalar& - y() { return (*this)[1]; } - - /** equivalent to operator[](2). */ - - IMP_EIGEN_STRONG_INLINE Scalar& - z() { return (*this)[2]; } - - /** equivalent to operator[](3). */ - - IMP_EIGEN_STRONG_INLINE Scalar& - w() { return (*this)[3]; } - - /** \internal - * Stores the given packet of coefficients, at the given row and column of this expression. It is your responsibility - * to ensure that a packet really starts there. This method is only available on expressions having the - * PacketAccessBit. - * - * The \a LoadMode parameter may have the value \a #Aligned or \a #Unaligned. Its effect is to select - * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets - * starting at an address which is a multiple of the packet size. - */ - - template - IMP_EIGEN_STRONG_INLINE void writePacket - (Index row, Index col, const typename internal::packet_traits::type& val) - { - imp_eigen_internal_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - derived().template writePacket(row,col,val); - } - - - /** \internal */ - template - IMP_EIGEN_STRONG_INLINE void writePacketByOuterInner - (Index outer, Index inner, const typename internal::packet_traits::type& val) - { - writePacket(rowIndexByOuterInner(outer, inner), - colIndexByOuterInner(outer, inner), - val); - } - - /** \internal - * Stores the given packet of coefficients, at the given index in this expression. It is your responsibility - * to ensure that a packet really starts there. This method is only available on expressions having the - * PacketAccessBit and the LinearAccessBit. - * - * The \a LoadMode parameter may have the value \a Aligned or \a Unaligned. Its effect is to select - * the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets - * starting at an address which is a multiple of the packet size. - */ - template - IMP_EIGEN_STRONG_INLINE void writePacket - (Index index, const typename internal::packet_traits::type& val) - { - imp_eigen_internal_assert(index >= 0 && index < size()); - derived().template writePacket(index,val); - } - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - - /** \internal Copies the coefficient at position (row,col) of other into *this. - * - * This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code - * with usual assignments. - * - * Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox. - */ - - template - IMP_EIGEN_STRONG_INLINE void copyCoeff(Index row, Index col, const DenseBase& other) - { - imp_eigen_internal_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - derived().coeffRef(row, col) = other.derived().coeff(row, col); - } - - /** \internal Copies the coefficient at the given index of other into *this. - * - * This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code - * with usual assignments. - * - * Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox. - */ - - template - IMP_EIGEN_STRONG_INLINE void copyCoeff(Index index, const DenseBase& other) - { - imp_eigen_internal_assert(index >= 0 && index < size()); - derived().coeffRef(index) = other.derived().coeff(index); - } - - - template - IMP_EIGEN_STRONG_INLINE void copyCoeffByOuterInner(Index outer, Index inner, const DenseBase& other) - { - const Index row = rowIndexByOuterInner(outer,inner); - const Index col = colIndexByOuterInner(outer,inner); - // derived() is important here: copyCoeff() may be reimplemented in Derived! - derived().copyCoeff(row, col, other); - } - - /** \internal Copies the packet at position (row,col) of other into *this. - * - * This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code - * with usual assignments. - * - * Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox. - */ - - template - IMP_EIGEN_STRONG_INLINE void copyPacket(Index row, Index col, const DenseBase& other) - { - imp_eigen_internal_assert(row >= 0 && row < rows() - && col >= 0 && col < cols()); - derived().template writePacket(row, col, - other.derived().template packet(row, col)); - } - - /** \internal Copies the packet at the given index of other into *this. - * - * This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code - * with usual assignments. - * - * Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox. - */ - - template - IMP_EIGEN_STRONG_INLINE void copyPacket(Index index, const DenseBase& other) - { - imp_eigen_internal_assert(index >= 0 && index < size()); - derived().template writePacket(index, - other.derived().template packet(index)); - } - - /** \internal */ - template - IMP_EIGEN_STRONG_INLINE void copyPacketByOuterInner(Index outer, Index inner, const DenseBase& other) - { - const Index row = rowIndexByOuterInner(outer,inner); - const Index col = colIndexByOuterInner(outer,inner); - // derived() is important here: copyCoeff() may be reimplemented in Derived! - derived().template copyPacket< OtherDerived, StoreMode, LoadMode>(row, col, other); - } -#endif - -}; - -/** \brief Base class providing direct read-only coefficient access to matrices and arrays. - * \ingroup Core_Module - * \tparam Derived Type of the derived class - * \tparam #DirectAccessors Constant indicating direct access - * - * This class defines functions to work with strides which can be used to access entries directly. This class - * inherits DenseCoeffsBase which defines functions to access entries read-only using - * \c operator() . - * - * \sa \ref TopicClassHierarchy - */ -template -class DenseCoeffsBase : public DenseCoeffsBase -{ - public: - - typedef DenseCoeffsBase Base; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; - - using Base::rows; - using Base::cols; - using Base::size; - using Base::derived; - - /** \returns the pointer increment between two consecutive elements within a slice in the inner direction. - * - * \sa outerStride(), rowStride(), colStride() - */ - inline Index innerStride() const - { - return derived().innerStride(); - } - - /** \returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns - * in a column-major matrix). - * - * \sa innerStride(), rowStride(), colStride() - */ - inline Index outerStride() const - { - return derived().outerStride(); - } - - // FIXME shall we remove it ? - inline Index stride() const - { - return Derived::IsVectorAtCompileTime ? innerStride() : outerStride(); - } - - /** \returns the pointer increment between two consecutive rows. - * - * \sa innerStride(), outerStride(), colStride() - */ - inline Index rowStride() const - { - return Derived::IsRowMajor ? outerStride() : innerStride(); - } - - /** \returns the pointer increment between two consecutive columns. - * - * \sa innerStride(), outerStride(), rowStride() - */ - inline Index colStride() const - { - return Derived::IsRowMajor ? innerStride() : outerStride(); - } -}; - -/** \brief Base class providing direct read/write coefficient access to matrices and arrays. - * \ingroup Core_Module - * \tparam Derived Type of the derived class - * \tparam #DirectWriteAccessors Constant indicating direct access - * - * This class defines functions to work with strides which can be used to access entries directly. This class - * inherits DenseCoeffsBase which defines functions to access entries read/write using - * \c operator(). - * - * \sa \ref TopicClassHierarchy - */ -template -class DenseCoeffsBase - : public DenseCoeffsBase -{ - public: - - typedef DenseCoeffsBase Base; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; - - using Base::rows; - using Base::cols; - using Base::size; - using Base::derived; - - /** \returns the pointer increment between two consecutive elements within a slice in the inner direction. - * - * \sa outerStride(), rowStride(), colStride() - */ - inline Index innerStride() const - { - return derived().innerStride(); - } - - /** \returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns - * in a column-major matrix). - * - * \sa innerStride(), rowStride(), colStride() - */ - inline Index outerStride() const - { - return derived().outerStride(); - } - - // FIXME shall we remove it ? - inline Index stride() const - { - return Derived::IsVectorAtCompileTime ? innerStride() : outerStride(); - } - - /** \returns the pointer increment between two consecutive rows. - * - * \sa innerStride(), outerStride(), colStride() - */ - inline Index rowStride() const - { - return Derived::IsRowMajor ? outerStride() : innerStride(); - } - - /** \returns the pointer increment between two consecutive columns. - * - * \sa innerStride(), outerStride(), rowStride() - */ - inline Index colStride() const - { - return Derived::IsRowMajor ? innerStride() : outerStride(); - } -}; - -namespace internal { - -template -struct first_aligned_impl -{ - static inline typename Derived::Index run(const Derived&) - { return 0; } -}; - -template -struct first_aligned_impl -{ - static inline typename Derived::Index run(const Derived& m) - { - return internal::first_aligned(&m.const_cast_derived().coeffRef(0,0), m.size()); - } -}; - -/** \internal \returns the index of the first element of the array that is well aligned for vectorization. - * - * There is also the variant first_aligned(const Scalar*, Integer) defined in Memory.h. See it for more - * documentation. - */ -template -static inline typename Derived::Index first_aligned(const Derived& m) -{ - return first_aligned_impl - - ::run(m); -} - -template::ret> -struct inner_stride_at_compile_time -{ - enum { ret = traits::InnerStrideAtCompileTime }; -}; - -template -struct inner_stride_at_compile_time -{ - enum { ret = 0 }; -}; - -template::ret> -struct outer_stride_at_compile_time -{ - enum { ret = traits::OuterStrideAtCompileTime }; -}; - -template -struct outer_stride_at_compile_time -{ - enum { ret = 0 }; -}; - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_DENSECOEFFSBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/DenseStorage.h b/modules/algebra/include/eigen3/Eigen/src/Core/DenseStorage.h deleted file mode 100644 index 99fcb09f66..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/DenseStorage.h +++ /dev/null @@ -1,434 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2006-2009 Benoit Jacob -// Copyright (C) 2010 Hauke Heibel -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_MATRIXSTORAGE_H -#define IMP_EIGEN_MATRIXSTORAGE_H - -#ifdef IMP_EIGEN_DENSE_STORAGE_CTOR_PLUGIN - #define IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN IMP_EIGEN_DENSE_STORAGE_CTOR_PLUGIN; -#else - #define IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN -#endif - -namespace IMP_Eigen { - -namespace internal { - -struct constructor_without_unaligned_array_assert {}; - -template void check_static_allocation_size() -{ - // if IMP_EIGEN_STACK_ALLOCATION_LIMIT is defined to 0, then no limit - #if IMP_EIGEN_STACK_ALLOCATION_LIMIT - IMP_EIGEN_STATIC_ASSERT(Size * sizeof(T) <= IMP_EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG); - #endif -} - -/** \internal - * Static array. If the MatrixOrArrayOptions require auto-alignment, the array will be automatically aligned: - * to 16 bytes boundary if the total size is a multiple of 16 bytes. - */ -template -struct plain_array -{ - T array[Size]; - - plain_array() - { - check_static_allocation_size(); - } - - plain_array(constructor_without_unaligned_array_assert) - { - check_static_allocation_size(); - } -}; - -#if defined(IMP_EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT) - #define IMP_EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) -#elif IMP_EIGEN_GNUC_AT_LEAST(4,7) - // GCC 4.7 is too aggressive in its optimizations and remove the alignement test based on the fact the array is declared to be aligned. - // See this bug report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53900 - // Hiding the origin of the array pointer behind a function argument seems to do the trick even if the function is inlined: - template - IMP_EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) { return array; } - #define IMP_EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ - imp_eigen_assert((reinterpret_cast(eigen_unaligned_array_assert_workaround_gcc47(array)) & sizemask) == 0 \ - && "this assertion is explained here: " \ - "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \ - " **** READ THIS WEB PAGE !!! ****"); -#else - #define IMP_EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ - imp_eigen_assert((reinterpret_cast(array) & sizemask) == 0 \ - && "this assertion is explained here: " \ - "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \ - " **** READ THIS WEB PAGE !!! ****"); -#endif - -template -struct plain_array -{ - IMP_EIGEN_USER_ALIGN16 T array[Size]; - - plain_array() - { - IMP_EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf); - check_static_allocation_size(); - } - - plain_array(constructor_without_unaligned_array_assert) - { - check_static_allocation_size(); - } -}; - -template -struct plain_array -{ - IMP_EIGEN_USER_ALIGN16 T array[1]; - plain_array() {} - plain_array(constructor_without_unaligned_array_assert) {} -}; - -} // end namespace internal - -/** \internal - * - * \class DenseStorage - * \ingroup Core_Module - * - * \brief Stores the data of a matrix - * - * This class stores the data of fixed-size, dynamic-size or mixed matrices - * in a way as compact as possible. - * - * \sa Matrix - */ -template class DenseStorage; - -// purely fixed-size matrix -template class DenseStorage -{ - internal::plain_array m_data; - public: - DenseStorage() {} - DenseStorage(internal::constructor_without_unaligned_array_assert) - : m_data(internal::constructor_without_unaligned_array_assert()) {} - DenseStorage(const DenseStorage& other) : m_data(other.m_data) {} - DenseStorage& operator=(const DenseStorage& other) - { - if (this != &other) m_data = other.m_data; - return *this; - } - DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} - void swap(DenseStorage& other) { std::swap(m_data,other.m_data); } - static DenseIndex rows(void) {return _Rows;} - static DenseIndex cols(void) {return _Cols;} - void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {} - void resize(DenseIndex,DenseIndex,DenseIndex) {} - const T *data() const { return m_data.array; } - T *data() { return m_data.array; } -}; - -// null matrix -template class DenseStorage -{ - public: - DenseStorage() {} - DenseStorage(internal::constructor_without_unaligned_array_assert) {} - DenseStorage(const DenseStorage&) {} - DenseStorage& operator=(const DenseStorage&) { return *this; } - DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} - void swap(DenseStorage& ) {} - static DenseIndex rows(void) {return _Rows;} - static DenseIndex cols(void) {return _Cols;} - void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {} - void resize(DenseIndex,DenseIndex,DenseIndex) {} - const T *data() const { return 0; } - T *data() { return 0; } -}; - -// more specializations for null matrices; these are necessary to resolve ambiguities -template class DenseStorage -: public DenseStorage { }; - -template class DenseStorage -: public DenseStorage { }; - -template class DenseStorage -: public DenseStorage { }; - -// dynamic-size matrix with fixed-size storage -template class DenseStorage -{ - internal::plain_array m_data; - DenseIndex m_rows; - DenseIndex m_cols; - public: - DenseStorage() : m_rows(0), m_cols(0) {} - DenseStorage(internal::constructor_without_unaligned_array_assert) - : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {} - DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {} - DenseStorage& operator=(const DenseStorage& other) - { - if (this != &other) - { - m_data = other.m_data; - m_rows = other.m_rows; - m_cols = other.m_cols; - } - return *this; - } - DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {} - void swap(DenseStorage& other) - { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } - DenseIndex rows() const {return m_rows;} - DenseIndex cols() const {return m_cols;} - void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; } - void resize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; } - const T *data() const { return m_data.array; } - T *data() { return m_data.array; } -}; - -// dynamic-size matrix with fixed-size storage and fixed width -template class DenseStorage -{ - internal::plain_array m_data; - DenseIndex m_rows; - public: - DenseStorage() : m_rows(0) {} - DenseStorage(internal::constructor_without_unaligned_array_assert) - : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {} - DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {} - DenseStorage& operator=(const DenseStorage& other) - { - if (this != &other) - { - m_data = other.m_data; - m_rows = other.m_rows; - } - return *this; - } - DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {} - void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } - DenseIndex rows(void) const {return m_rows;} - DenseIndex cols(void) const {return _Cols;} - void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; } - void resize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; } - const T *data() const { return m_data.array; } - T *data() { return m_data.array; } -}; - -// dynamic-size matrix with fixed-size storage and fixed height -template class DenseStorage -{ - internal::plain_array m_data; - DenseIndex m_cols; - public: - DenseStorage() : m_cols(0) {} - DenseStorage(internal::constructor_without_unaligned_array_assert) - : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {} - DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {} - DenseStorage& operator=(const DenseStorage& other) - { - if (this != &other) - { - m_data = other.m_data; - m_cols = other.m_cols; - } - return *this; - } - DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {} - void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } - DenseIndex rows(void) const {return _Rows;} - DenseIndex cols(void) const {return m_cols;} - void conservativeResize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; } - void resize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; } - const T *data() const { return m_data.array; } - T *data() { return m_data.array; } -}; - -// purely dynamic matrix. -template class DenseStorage -{ - T *m_data; - DenseIndex m_rows; - DenseIndex m_cols; - public: - DenseStorage() : m_data(0), m_rows(0), m_cols(0) {} - DenseStorage(internal::constructor_without_unaligned_array_assert) - : m_data(0), m_rows(0), m_cols(0) {} - DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols) - : m_data(internal::conditional_aligned_new_auto(size)), m_rows(nbRows), m_cols(nbCols) - { IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } -#ifdef IMP_EIGEN_HAVE_RVALUE_REFERENCES - DenseStorage(DenseStorage&& other) - : m_data(std::move(other.m_data)) - , m_rows(std::move(other.m_rows)) - , m_cols(std::move(other.m_cols)) - { - other.m_data = nullptr; - } - DenseStorage& operator=(DenseStorage&& other) - { - using std::swap; - swap(m_data, other.m_data); - swap(m_rows, other.m_rows); - swap(m_cols, other.m_cols); - return *this; - } -#endif - ~DenseStorage() { internal::conditional_aligned_delete_auto(m_data, m_rows*m_cols); } - void swap(DenseStorage& other) - { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } - DenseIndex rows(void) const {return m_rows;} - DenseIndex cols(void) const {return m_cols;} - void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols) - { - m_data = internal::conditional_aligned_realloc_new_auto(m_data, size, m_rows*m_cols); - m_rows = nbRows; - m_cols = nbCols; - } - void resize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols) - { - if(size != m_rows*m_cols) - { - internal::conditional_aligned_delete_auto(m_data, m_rows*m_cols); - if (size) - m_data = internal::conditional_aligned_new_auto(size); - else - m_data = 0; - IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN - } - m_rows = nbRows; - m_cols = nbCols; - } - const T *data() const { return m_data; } - T *data() { return m_data; } - private: - DenseStorage(const DenseStorage&); - DenseStorage& operator=(const DenseStorage&); -}; - -// matrix with dynamic width and fixed height (so that matrix has dynamic size). -template class DenseStorage -{ - T *m_data; - DenseIndex m_cols; - public: - DenseStorage() : m_data(0), m_cols(0) {} - DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {} - DenseStorage(DenseIndex size, DenseIndex, DenseIndex nbCols) : m_data(internal::conditional_aligned_new_auto(size)), m_cols(nbCols) - { IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } -#ifdef IMP_EIGEN_HAVE_RVALUE_REFERENCES - DenseStorage(DenseStorage&& other) - : m_data(std::move(other.m_data)) - , m_cols(std::move(other.m_cols)) - { - other.m_data = nullptr; - } - DenseStorage& operator=(DenseStorage&& other) - { - using std::swap; - swap(m_data, other.m_data); - swap(m_cols, other.m_cols); - return *this; - } -#endif - ~DenseStorage() { internal::conditional_aligned_delete_auto(m_data, _Rows*m_cols); } - void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } - static DenseIndex rows(void) {return _Rows;} - DenseIndex cols(void) const {return m_cols;} - void conservativeResize(DenseIndex size, DenseIndex, DenseIndex nbCols) - { - m_data = internal::conditional_aligned_realloc_new_auto(m_data, size, _Rows*m_cols); - m_cols = nbCols; - } - IMP_EIGEN_STRONG_INLINE void resize(DenseIndex size, DenseIndex, DenseIndex nbCols) - { - if(size != _Rows*m_cols) - { - internal::conditional_aligned_delete_auto(m_data, _Rows*m_cols); - if (size) - m_data = internal::conditional_aligned_new_auto(size); - else - m_data = 0; - IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN - } - m_cols = nbCols; - } - const T *data() const { return m_data; } - T *data() { return m_data; } - private: - DenseStorage(const DenseStorage&); - DenseStorage& operator=(const DenseStorage&); -}; - -// matrix with dynamic height and fixed width (so that matrix has dynamic size). -template class DenseStorage -{ - T *m_data; - DenseIndex m_rows; - public: - DenseStorage() : m_data(0), m_rows(0) {} - DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {} - DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex) : m_data(internal::conditional_aligned_new_auto(size)), m_rows(nbRows) - { IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } -#ifdef IMP_EIGEN_HAVE_RVALUE_REFERENCES - DenseStorage(DenseStorage&& other) - : m_data(std::move(other.m_data)) - , m_rows(std::move(other.m_rows)) - { - other.m_data = nullptr; - } - DenseStorage& operator=(DenseStorage&& other) - { - using std::swap; - swap(m_data, other.m_data); - swap(m_rows, other.m_rows); - return *this; - } -#endif - ~DenseStorage() { internal::conditional_aligned_delete_auto(m_data, _Cols*m_rows); } - void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } - DenseIndex rows(void) const {return m_rows;} - static DenseIndex cols(void) {return _Cols;} - void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex) - { - m_data = internal::conditional_aligned_realloc_new_auto(m_data, size, m_rows*_Cols); - m_rows = nbRows; - } - IMP_EIGEN_STRONG_INLINE void resize(DenseIndex size, DenseIndex nbRows, DenseIndex) - { - if(size != m_rows*_Cols) - { - internal::conditional_aligned_delete_auto(m_data, _Cols*m_rows); - if (size) - m_data = internal::conditional_aligned_new_auto(size); - else - m_data = 0; - IMP_EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN - } - m_rows = nbRows; - } - const T *data() const { return m_data; } - T *data() { return m_data; } - private: - DenseStorage(const DenseStorage&); - DenseStorage& operator=(const DenseStorage&); -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_MATRIX_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Diagonal.h b/modules/algebra/include/eigen3/Eigen/src/Core/Diagonal.h deleted file mode 100644 index 7102525faf..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Diagonal.h +++ /dev/null @@ -1,237 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2007-2009 Benoit Jacob -// Copyright (C) 2009-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_DIAGONAL_H -#define IMP_EIGEN_DIAGONAL_H - -namespace IMP_Eigen { - -/** \class Diagonal - * \ingroup Core_Module - * - * \brief Expression of a diagonal/subdiagonal/superdiagonal in a matrix - * - * \param MatrixType the type of the object in which we are taking a sub/main/super diagonal - * \param DiagIndex the index of the sub/super diagonal. The default is 0 and it means the main diagonal. - * A positive value means a superdiagonal, a negative value means a subdiagonal. - * You can also use Dynamic so the index can be set at runtime. - * - * The matrix is not required to be square. - * - * This class represents an expression of the main diagonal, or any sub/super diagonal - * of a square matrix. It is the return type of MatrixBase::diagonal() and MatrixBase::diagonal(Index) and most of the - * time this is the only way it is used. - * - * \sa MatrixBase::diagonal(), MatrixBase::diagonal(Index) - */ - -namespace internal { -template -struct traits > - : traits -{ - typedef typename nested::type MatrixTypeNested; - typedef typename remove_reference::type _MatrixTypeNested; - typedef typename MatrixType::StorageKind StorageKind; - enum { - RowsAtCompileTime = (int(DiagIndex) == DynamicIndex || int(MatrixType::SizeAtCompileTime) == Dynamic) ? Dynamic - : (IMP_EIGEN_PLAIN_ENUM_MIN(MatrixType::RowsAtCompileTime - IMP_EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0), - MatrixType::ColsAtCompileTime - IMP_EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))), - ColsAtCompileTime = 1, - MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic - : DiagIndex == DynamicIndex ? IMP_EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime, - MatrixType::MaxColsAtCompileTime) - : (IMP_EIGEN_PLAIN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime - IMP_EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0), - MatrixType::MaxColsAtCompileTime - IMP_EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))), - MaxColsAtCompileTime = 1, - MaskLvalueBit = is_lvalue::value ? LvalueBit : 0, - Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit | MaskLvalueBit | DirectAccessBit) & ~RowMajorBit, - CoeffReadCost = _MatrixTypeNested::CoeffReadCost, - MatrixTypeOuterStride = outer_stride_at_compile_time::ret, - InnerStrideAtCompileTime = MatrixTypeOuterStride == Dynamic ? Dynamic : MatrixTypeOuterStride+1, - OuterStrideAtCompileTime = 0 - }; -}; -} - -template class Diagonal - : public internal::dense_xpr_base< Diagonal >::type -{ - public: - - enum { DiagIndex = _DiagIndex }; - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal) - - inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index) {} - - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal) - - inline Index rows() const - { return m_index.value()<0 ? (std::min)(m_matrix.cols(),m_matrix.rows()+m_index.value()) : (std::min)(m_matrix.rows(),m_matrix.cols()-m_index.value()); } - - inline Index cols() const { return 1; } - - inline Index innerStride() const - { - return m_matrix.outerStride() + 1; - } - - inline Index outerStride() const - { - return 0; - } - - typedef typename internal::conditional< - internal::is_lvalue::value, - Scalar, - const Scalar - >::type ScalarWithConstIfNotLvalue; - - inline ScalarWithConstIfNotLvalue* data() { return &(m_matrix.const_cast_derived().coeffRef(rowOffset(), colOffset())); } - inline const Scalar* data() const { return &(m_matrix.const_cast_derived().coeffRef(rowOffset(), colOffset())); } - - inline Scalar& coeffRef(Index row, Index) - { - IMP_EIGEN_STATIC_ASSERT_LVALUE(MatrixType) - return m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset()); - } - - inline const Scalar& coeffRef(Index row, Index) const - { - return m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset()); - } - - inline CoeffReturnType coeff(Index row, Index) const - { - return m_matrix.coeff(row+rowOffset(), row+colOffset()); - } - - inline Scalar& coeffRef(Index idx) - { - IMP_EIGEN_STATIC_ASSERT_LVALUE(MatrixType) - return m_matrix.const_cast_derived().coeffRef(idx+rowOffset(), idx+colOffset()); - } - - inline const Scalar& coeffRef(Index idx) const - { - return m_matrix.const_cast_derived().coeffRef(idx+rowOffset(), idx+colOffset()); - } - - inline CoeffReturnType coeff(Index idx) const - { - return m_matrix.coeff(idx+rowOffset(), idx+colOffset()); - } - - const typename internal::remove_all::type& - nestedExpression() const - { - return m_matrix; - } - - int index() const - { - return m_index.value(); - } - - protected: - typename MatrixType::Nested m_matrix; - const internal::variable_if_dynamicindex m_index; - - private: - // some compilers may fail to optimize std::max etc in case of compile-time constants... - IMP_EIGEN_STRONG_INLINE Index absDiagIndex() const { return m_index.value()>0 ? m_index.value() : -m_index.value(); } - IMP_EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value()>0 ? 0 : -m_index.value(); } - IMP_EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value()>0 ? m_index.value() : 0; } - // triger a compile time error is someone try to call packet - template typename MatrixType::PacketReturnType packet(Index) const; - template typename MatrixType::PacketReturnType packet(Index,Index) const; -}; - -/** \returns an expression of the main diagonal of the matrix \c *this - * - * \c *this is not required to be square. - * - * Example: \include MatrixBase_diagonal.cpp - * Output: \verbinclude MatrixBase_diagonal.out - * - * \sa class Diagonal */ -template -inline typename MatrixBase::DiagonalReturnType -MatrixBase::diagonal() -{ - return derived(); -} - -/** This is the const version of diagonal(). */ -template -inline typename MatrixBase::ConstDiagonalReturnType -MatrixBase::diagonal() const -{ - return ConstDiagonalReturnType(derived()); -} - -/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this - * - * \c *this is not required to be square. - * - * The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex > 0 - * and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal. - * - * Example: \include MatrixBase_diagonal_int.cpp - * Output: \verbinclude MatrixBase_diagonal_int.out - * - * \sa MatrixBase::diagonal(), class Diagonal */ -template -inline typename MatrixBase::DiagonalDynamicIndexReturnType -MatrixBase::diagonal(Index index) -{ - return DiagonalDynamicIndexReturnType(derived(), index); -} - -/** This is the const version of diagonal(Index). */ -template -inline typename MatrixBase::ConstDiagonalDynamicIndexReturnType -MatrixBase::diagonal(Index index) const -{ - return ConstDiagonalDynamicIndexReturnType(derived(), index); -} - -/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this - * - * \c *this is not required to be square. - * - * The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex > 0 - * and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal. - * - * Example: \include MatrixBase_diagonal_template_int.cpp - * Output: \verbinclude MatrixBase_diagonal_template_int.out - * - * \sa MatrixBase::diagonal(), class Diagonal */ -template -template -inline typename MatrixBase::template DiagonalIndexReturnType::Type -MatrixBase::diagonal() -{ - return derived(); -} - -/** This is the const version of diagonal(). */ -template -template -inline typename MatrixBase::template ConstDiagonalIndexReturnType::Type -MatrixBase::diagonal() const -{ - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_DIAGONAL_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/DiagonalMatrix.h b/modules/algebra/include/eigen3/Eigen/src/Core/DiagonalMatrix.h deleted file mode 100644 index b857b00916..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/DiagonalMatrix.h +++ /dev/null @@ -1,313 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// Copyright (C) 2007-2009 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_DIAGONALMATRIX_H -#define IMP_EIGEN_DIAGONALMATRIX_H - -namespace IMP_Eigen { - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN -template -class DiagonalBase : public EigenBase -{ - public: - typedef typename internal::traits::DiagonalVectorType DiagonalVectorType; - typedef typename DiagonalVectorType::Scalar Scalar; - typedef typename DiagonalVectorType::RealScalar RealScalar; - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - - enum { - RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, - ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, - MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime, - MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime, - IsVectorAtCompileTime = 0, - Flags = 0 - }; - - typedef Matrix DenseMatrixType; - typedef DenseMatrixType DenseType; - typedef DiagonalMatrix PlainObject; - - inline const Derived& derived() const { return *static_cast(this); } - inline Derived& derived() { return *static_cast(this); } - - DenseMatrixType toDenseMatrix() const { return derived(); } - template - void evalTo(MatrixBase &other) const; - template - inline void addTo(MatrixBase &other) const - { other.diagonal() += diagonal(); } - template - inline void subTo(MatrixBase &other) const - { other.diagonal() -= diagonal(); } - - inline const DiagonalVectorType& diagonal() const { return derived().diagonal(); } - inline DiagonalVectorType& diagonal() { return derived().diagonal(); } - - inline Index rows() const { return diagonal().size(); } - inline Index cols() const { return diagonal().size(); } - - /** \returns the diagonal matrix product of \c *this by the matrix \a matrix. - */ - template - const DiagonalProduct - operator*(const MatrixBase &matrix) const - { - return DiagonalProduct(matrix.derived(), derived()); - } - - inline const DiagonalWrapper, const DiagonalVectorType> > - inverse() const - { - return diagonal().cwiseInverse(); - } - - inline const DiagonalWrapper, const DiagonalVectorType> > - operator*(const Scalar& scalar) const - { - return diagonal() * scalar; - } - friend inline const DiagonalWrapper, const DiagonalVectorType> > - operator*(const Scalar& scalar, const DiagonalBase& other) - { - return other.diagonal() * scalar; - } - - #ifdef IMP_EIGEN2_SUPPORT - template - bool isApprox(const DiagonalBase& other, typename NumTraits::Real precision = NumTraits::dummy_precision()) const - { - return diagonal().isApprox(other.diagonal(), precision); - } - template - bool isApprox(const MatrixBase& other, typename NumTraits::Real precision = NumTraits::dummy_precision()) const - { - return toDenseMatrix().isApprox(other, precision); - } - #endif -}; - -template -template -inline void DiagonalBase::evalTo(MatrixBase &other) const -{ - other.setZero(); - other.diagonal() = diagonal(); -} -#endif - -/** \class DiagonalMatrix - * \ingroup Core_Module - * - * \brief Represents a diagonal matrix with its storage - * - * \param _Scalar the type of coefficients - * \param SizeAtCompileTime the dimension of the matrix, or Dynamic - * \param MaxSizeAtCompileTime the dimension of the matrix, or Dynamic. This parameter is optional and defaults - * to SizeAtCompileTime. Most of the time, you do not need to specify it. - * - * \sa class DiagonalWrapper - */ - -namespace internal { -template -struct traits > - : traits > -{ - typedef Matrix<_Scalar,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1> DiagonalVectorType; - typedef Dense StorageKind; - typedef DenseIndex Index; - enum { - Flags = LvalueBit - }; -}; -} -template -class DiagonalMatrix - : public DiagonalBase > -{ - public: - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef typename internal::traits::DiagonalVectorType DiagonalVectorType; - typedef const DiagonalMatrix& Nested; - typedef _Scalar Scalar; - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - #endif - - protected: - - DiagonalVectorType m_diagonal; - - public: - - /** const version of diagonal(). */ - inline const DiagonalVectorType& diagonal() const { return m_diagonal; } - /** \returns a reference to the stored vector of diagonal coefficients. */ - inline DiagonalVectorType& diagonal() { return m_diagonal; } - - /** Default constructor without initialization */ - inline DiagonalMatrix() {} - - /** Constructs a diagonal matrix with given dimension */ - inline DiagonalMatrix(Index dim) : m_diagonal(dim) {} - - /** 2D constructor. */ - inline DiagonalMatrix(const Scalar& x, const Scalar& y) : m_diagonal(x,y) {} - - /** 3D constructor. */ - inline DiagonalMatrix(const Scalar& x, const Scalar& y, const Scalar& z) : m_diagonal(x,y,z) {} - - /** Copy constructor. */ - template - inline DiagonalMatrix(const DiagonalBase& other) : m_diagonal(other.diagonal()) {} - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** copy constructor. prevent a default copy constructor from hiding the other templated constructor */ - inline DiagonalMatrix(const DiagonalMatrix& other) : m_diagonal(other.diagonal()) {} - #endif - - /** generic constructor from expression of the diagonal coefficients */ - template - explicit inline DiagonalMatrix(const MatrixBase& other) : m_diagonal(other) - {} - - /** Copy operator. */ - template - DiagonalMatrix& operator=(const DiagonalBase& other) - { - m_diagonal = other.diagonal(); - return *this; - } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** This is a special case of the templated operator=. Its purpose is to - * prevent a default operator= from hiding the templated operator=. - */ - DiagonalMatrix& operator=(const DiagonalMatrix& other) - { - m_diagonal = other.diagonal(); - return *this; - } - #endif - - /** Resizes to given size. */ - inline void resize(Index size) { m_diagonal.resize(size); } - /** Sets all coefficients to zero. */ - inline void setZero() { m_diagonal.setZero(); } - /** Resizes and sets all coefficients to zero. */ - inline void setZero(Index size) { m_diagonal.setZero(size); } - /** Sets this matrix to be the identity matrix of the current size. */ - inline void setIdentity() { m_diagonal.setOnes(); } - /** Sets this matrix to be the identity matrix of the given size. */ - inline void setIdentity(Index size) { m_diagonal.setOnes(size); } -}; - -/** \class DiagonalWrapper - * \ingroup Core_Module - * - * \brief Expression of a diagonal matrix - * - * \param _DiagonalVectorType the type of the vector of diagonal coefficients - * - * This class is an expression of a diagonal matrix, but not storing its own vector of diagonal coefficients, - * instead wrapping an existing vector expression. It is the return type of MatrixBase::asDiagonal() - * and most of the time this is the only way that it is used. - * - * \sa class DiagonalMatrix, class DiagonalBase, MatrixBase::asDiagonal() - */ - -namespace internal { -template -struct traits > -{ - typedef _DiagonalVectorType DiagonalVectorType; - typedef typename DiagonalVectorType::Scalar Scalar; - typedef typename DiagonalVectorType::Index Index; - typedef typename DiagonalVectorType::StorageKind StorageKind; - enum { - RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, - ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, - MaxRowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, - MaxColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, - Flags = traits::Flags & LvalueBit - }; -}; -} - -template -class DiagonalWrapper - : public DiagonalBase >, internal::no_assignment_operator -{ - public: - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef _DiagonalVectorType DiagonalVectorType; - typedef DiagonalWrapper Nested; - #endif - - /** Constructor from expression of diagonal coefficients to wrap. */ - inline DiagonalWrapper(DiagonalVectorType& a_diagonal) : m_diagonal(a_diagonal) {} - - /** \returns a const reference to the wrapped expression of diagonal coefficients. */ - const DiagonalVectorType& diagonal() const { return m_diagonal; } - - protected: - typename DiagonalVectorType::Nested m_diagonal; -}; - -/** \returns a pseudo-expression of a diagonal matrix with *this as vector of diagonal coefficients - * - * \only_for_vectors - * - * Example: \include MatrixBase_asDiagonal.cpp - * Output: \verbinclude MatrixBase_asDiagonal.out - * - * \sa class DiagonalWrapper, class DiagonalMatrix, diagonal(), isDiagonal() - **/ -template -inline const DiagonalWrapper -MatrixBase::asDiagonal() const -{ - return derived(); -} - -/** \returns true if *this is approximately equal to a diagonal matrix, - * within the precision given by \a prec. - * - * Example: \include MatrixBase_isDiagonal.cpp - * Output: \verbinclude MatrixBase_isDiagonal.out - * - * \sa asDiagonal() - */ -template -bool MatrixBase::isDiagonal(const RealScalar& prec) const -{ - using std::abs; - if(cols() != rows()) return false; - RealScalar maxAbsOnDiagonal = static_cast(-1); - for(Index j = 0; j < cols(); ++j) - { - RealScalar absOnDiagonal = abs(coeff(j,j)); - if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal; - } - for(Index j = 0; j < cols(); ++j) - for(Index i = 0; i < j; ++i) - { - if(!internal::isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false; - if(!internal::isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false; - } - return true; -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_DIAGONALMATRIX_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/DiagonalProduct.h b/modules/algebra/include/eigen3/Eigen/src/Core/DiagonalProduct.h deleted file mode 100644 index 5d928e01c6..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/DiagonalProduct.h +++ /dev/null @@ -1,131 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2007-2009 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_DIAGONALPRODUCT_H -#define IMP_EIGEN_DIAGONALPRODUCT_H - -namespace IMP_Eigen { - -namespace internal { -template -struct traits > - : traits -{ - typedef typename scalar_product_traits::ReturnType Scalar; - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - - _StorageOrder = MatrixType::Flags & RowMajorBit ? RowMajor : ColMajor, - _ScalarAccessOnDiag = !((int(_StorageOrder) == ColMajor && int(ProductOrder) == OnTheLeft) - ||(int(_StorageOrder) == RowMajor && int(ProductOrder) == OnTheRight)), - _SameTypes = is_same::value, - // FIXME currently we need same types, but in the future the next rule should be the one - //_Vectorizable = bool(int(MatrixType::Flags)&PacketAccessBit) && ((!_PacketOnDiag) || (_SameTypes && bool(int(DiagonalType::DiagonalVectorType::Flags)&PacketAccessBit))), - _Vectorizable = bool(int(MatrixType::Flags)&PacketAccessBit) && _SameTypes && (_ScalarAccessOnDiag || (bool(int(DiagonalType::DiagonalVectorType::Flags)&PacketAccessBit))), - _LinearAccessMask = (RowsAtCompileTime==1 || ColsAtCompileTime==1) ? LinearAccessBit : 0, - - Flags = ((HereditaryBits|_LinearAccessMask|AlignedBit) & (unsigned int)(MatrixType::Flags)) | (_Vectorizable ? PacketAccessBit : 0),//(int(MatrixType::Flags)&int(DiagonalType::DiagonalVectorType::Flags)&AlignedBit), - Cost0 = IMP_EIGEN_ADD_COST(NumTraits::MulCost, MatrixType::CoeffReadCost), - CoeffReadCost = IMP_EIGEN_ADD_COST(Cost0,DiagonalType::DiagonalVectorType::CoeffReadCost) - }; -}; -} - -template -class DiagonalProduct : internal::no_assignment_operator, - public MatrixBase > -{ - public: - - typedef MatrixBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(DiagonalProduct) - - inline DiagonalProduct(const MatrixType& matrix, const DiagonalType& diagonal) - : m_matrix(matrix), m_diagonal(diagonal) - { - imp_eigen_assert(diagonal.diagonal().size() == (ProductOrder == OnTheLeft ? matrix.rows() : matrix.cols())); - } - - IMP_EIGEN_STRONG_INLINE Index rows() const { return m_matrix.rows(); } - IMP_EIGEN_STRONG_INLINE Index cols() const { return m_matrix.cols(); } - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index row, Index col) const - { - return m_diagonal.diagonal().coeff(ProductOrder == OnTheLeft ? row : col) * m_matrix.coeff(row, col); - } - - IMP_EIGEN_STRONG_INLINE const Scalar coeff(Index idx) const - { - enum { - StorageOrder = int(MatrixType::Flags) & RowMajorBit ? RowMajor : ColMajor - }; - return coeff(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const - { - enum { - StorageOrder = Flags & RowMajorBit ? RowMajor : ColMajor - }; - const Index indexInDiagonalVector = ProductOrder == OnTheLeft ? row : col; - return packet_impl(row,col,indexInDiagonalVector,typename internal::conditional< - ((int(StorageOrder) == RowMajor && int(ProductOrder) == OnTheLeft) - ||(int(StorageOrder) == ColMajor && int(ProductOrder) == OnTheRight)), internal::true_type, internal::false_type>::type()); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index idx) const - { - enum { - StorageOrder = int(MatrixType::Flags) & RowMajorBit ? RowMajor : ColMajor - }; - return packet(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); - } - - protected: - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, internal::true_type) const - { - return internal::pmul(m_matrix.template packet(row, col), - internal::pset1(m_diagonal.diagonal().coeff(id))); - } - - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, internal::false_type) const - { - enum { - InnerSize = (MatrixType::Flags & RowMajorBit) ? MatrixType::ColsAtCompileTime : MatrixType::RowsAtCompileTime, - DiagonalVectorPacketLoadMode = (LoadMode == Aligned && (((InnerSize%16) == 0) || (int(DiagonalType::DiagonalVectorType::Flags)&AlignedBit)==AlignedBit) ? Aligned : Unaligned) - }; - return internal::pmul(m_matrix.template packet(row, col), - m_diagonal.diagonal().template packet(id)); - } - - typename MatrixType::Nested m_matrix; - typename DiagonalType::Nested m_diagonal; -}; - -/** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. - */ -template -template -inline const DiagonalProduct -MatrixBase::operator*(const DiagonalBase &a_diagonal) const -{ - return DiagonalProduct(derived(), a_diagonal.derived()); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_DIAGONALPRODUCT_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Dot.h b/modules/algebra/include/eigen3/Eigen/src/Core/Dot.h deleted file mode 100644 index 08361be5ff..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Dot.h +++ /dev/null @@ -1,263 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2008, 2010 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_DOT_H -#define IMP_EIGEN_DOT_H - -namespace IMP_Eigen { - -namespace internal { - -// helper function for dot(). The problem is that if we put that in the body of dot(), then upon calling dot -// with mismatched types, the compiler emits errors about failing to instantiate cwiseProduct BEFORE -// looking at the static assertions. Thus this is a trick to get better compile errors. -template -struct dot_nocheck -{ - typedef typename scalar_product_traits::Scalar,typename traits::Scalar>::ReturnType ResScalar; - static inline ResScalar run(const MatrixBase& a, const MatrixBase& b) - { - return a.template binaryExpr::Scalar,typename traits::Scalar> >(b).sum(); - } -}; - -template -struct dot_nocheck -{ - typedef typename scalar_product_traits::Scalar,typename traits::Scalar>::ReturnType ResScalar; - static inline ResScalar run(const MatrixBase& a, const MatrixBase& b) - { - return a.transpose().template binaryExpr::Scalar,typename traits::Scalar> >(b).sum(); - } -}; - -} // end namespace internal - -/** \returns the dot product of *this with other. - * - * \only_for_vectors - * - * \note If the scalar type is complex numbers, then this function returns the hermitian - * (sesquilinear) dot product, conjugate-linear in the first variable and linear in the - * second variable. - * - * \sa squaredNorm(), norm() - */ -template -template -inline typename internal::scalar_product_traits::Scalar,typename internal::traits::Scalar>::ReturnType -MatrixBase::dot(const MatrixBase& other) const -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) - IMP_EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) - typedef internal::scalar_conj_product_op func; - IMP_EIGEN_CHECK_BINARY_COMPATIBILIY(func,Scalar,typename OtherDerived::Scalar); - - imp_eigen_assert(size() == other.size()); - - return internal::dot_nocheck::run(*this, other); -} - -#ifdef IMP_EIGEN2_SUPPORT -/** \returns the dot product of *this with other, with the Eigen2 convention that the dot product is linear in the first variable - * (conjugating the second variable). Of course this only makes a difference in the complex case. - * - * This method is only available in IMP_EIGEN2_SUPPORT mode. - * - * \only_for_vectors - * - * \sa dot() - */ -template -template -typename internal::traits::Scalar -MatrixBase::eigen2_dot(const MatrixBase& other) const -{ - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) - IMP_EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) - IMP_EIGEN_STATIC_ASSERT((internal::is_same::value), - YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - - imp_eigen_assert(size() == other.size()); - - return internal::dot_nocheck::run(other,*this); -} -#endif - - -//---------- implementation of L2 norm and related functions ---------- - -/** \returns, for vectors, the squared \em l2 norm of \c *this, and for matrices the Frobenius norm. - * In both cases, it consists in the sum of the square of all the matrix entries. - * For vectors, this is also equals to the dot product of \c *this with itself. - * - * \sa dot(), norm() - */ -template -IMP_EIGEN_STRONG_INLINE typename NumTraits::Scalar>::Real MatrixBase::squaredNorm() const -{ - return numext::real((*this).cwiseAbs2().sum()); -} - -/** \returns, for vectors, the \em l2 norm of \c *this, and for matrices the Frobenius norm. - * In both cases, it consists in the square root of the sum of the square of all the matrix entries. - * For vectors, this is also equals to the square root of the dot product of \c *this with itself. - * - * \sa dot(), squaredNorm() - */ -template -inline typename NumTraits::Scalar>::Real MatrixBase::norm() const -{ - using std::sqrt; - return sqrt(squaredNorm()); -} - -/** \returns an expression of the quotient of *this by its own norm. - * - * \only_for_vectors - * - * \sa norm(), normalize() - */ -template -inline const typename MatrixBase::PlainObject -MatrixBase::normalized() const -{ - typedef typename internal::nested::type Nested; - typedef typename internal::remove_reference::type _Nested; - _Nested n(derived()); - return n / n.norm(); -} - -/** Normalizes the vector, i.e. divides it by its own norm. - * - * \only_for_vectors - * - * \sa norm(), normalized() - */ -template -inline void MatrixBase::normalize() -{ - *this /= norm(); -} - -//---------- implementation of other norms ---------- - -namespace internal { - -template -struct lpNorm_selector -{ - typedef typename NumTraits::Scalar>::Real RealScalar; - static inline RealScalar run(const MatrixBase& m) - { - using std::pow; - return pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p); - } -}; - -template -struct lpNorm_selector -{ - static inline typename NumTraits::Scalar>::Real run(const MatrixBase& m) - { - return m.cwiseAbs().sum(); - } -}; - -template -struct lpNorm_selector -{ - static inline typename NumTraits::Scalar>::Real run(const MatrixBase& m) - { - return m.norm(); - } -}; - -template -struct lpNorm_selector -{ - static inline typename NumTraits::Scalar>::Real run(const MatrixBase& m) - { - return m.cwiseAbs().maxCoeff(); - } -}; - -} // end namespace internal - -/** \returns the \f$ \ell^p \f$ norm of *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values - * of the coefficients of *this. If \a p is the special value \a IMP_Eigen::Infinity, this function returns the \f$ \ell^\infty \f$ - * norm, that is the maximum of the absolute values of the coefficients of *this. - * - * \sa norm() - */ -template -template -inline typename NumTraits::Scalar>::Real -MatrixBase::lpNorm() const -{ - return internal::lpNorm_selector::run(*this); -} - -//---------- implementation of isOrthogonal / isUnitary ---------- - -/** \returns true if *this is approximately orthogonal to \a other, - * within the precision given by \a prec. - * - * Example: \include MatrixBase_isOrthogonal.cpp - * Output: \verbinclude MatrixBase_isOrthogonal.out - */ -template -template -bool MatrixBase::isOrthogonal -(const MatrixBase& other, const RealScalar& prec) const -{ - typename internal::nested::type nested(derived()); - typename internal::nested::type otherNested(other.derived()); - return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm(); -} - -/** \returns true if *this is approximately an unitary matrix, - * within the precision given by \a prec. In the case where the \a Scalar - * type is real numbers, a unitary matrix is an orthogonal matrix, whence the name. - * - * \note This can be used to check whether a family of vectors forms an orthonormal basis. - * Indeed, \c m.isUnitary() returns true if and only if the columns (equivalently, the rows) of m form an - * orthonormal basis. - * - * Example: \include MatrixBase_isUnitary.cpp - * Output: \verbinclude MatrixBase_isUnitary.out - */ -template -bool MatrixBase::isUnitary(const RealScalar& prec) const -{ - typename Derived::Nested nested(derived()); - for(Index i = 0; i < cols(); ++i) - { - if(!internal::isApprox(nested.col(i).squaredNorm(), static_cast(1), prec)) - return false; - for(Index j = 0; j < i; ++j) - if(!internal::isMuchSmallerThan(nested.col(i).dot(nested.col(j)), static_cast(1), prec)) - return false; - } - return true; -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_DOT_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/EigenBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/EigenBase.h deleted file mode 100644 index ae98dd20af..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/EigenBase.h +++ /dev/null @@ -1,131 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Benoit Jacob -// Copyright (C) 2009 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_EIGENBASE_H -#define IMP_EIGEN_EIGENBASE_H - -namespace IMP_Eigen { - -/** Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T). - * - * In other words, an EigenBase object is an object that can be copied into a MatrixBase. - * - * Besides MatrixBase-derived classes, this also includes special matrix classes such as diagonal matrices, etc. - * - * Notice that this class is trivial, it is only used to disambiguate overloaded functions. - * - * \sa \ref TopicClassHierarchy - */ -template struct EigenBase -{ -// typedef typename internal::plain_matrix_type::type PlainObject; - - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - - /** \returns a reference to the derived object */ - Derived& derived() { return *static_cast(this); } - /** \returns a const reference to the derived object */ - const Derived& derived() const { return *static_cast(this); } - - inline Derived& const_cast_derived() const - { return *static_cast(const_cast(this)); } - inline const Derived& const_derived() const - { return *static_cast(this); } - - /** \returns the number of rows. \sa cols(), RowsAtCompileTime */ - inline Index rows() const { return derived().rows(); } - /** \returns the number of columns. \sa rows(), ColsAtCompileTime*/ - inline Index cols() const { return derived().cols(); } - /** \returns the number of coefficients, which is rows()*cols(). - * \sa rows(), cols(), SizeAtCompileTime. */ - inline Index size() const { return rows() * cols(); } - - /** \internal Don't use it, but do the equivalent: \code dst = *this; \endcode */ - template inline void evalTo(Dest& dst) const - { derived().evalTo(dst); } - - /** \internal Don't use it, but do the equivalent: \code dst += *this; \endcode */ - template inline void addTo(Dest& dst) const - { - // This is the default implementation, - // derived class can reimplement it in a more optimized way. - typename Dest::PlainObject res(rows(),cols()); - evalTo(res); - dst += res; - } - - /** \internal Don't use it, but do the equivalent: \code dst -= *this; \endcode */ - template inline void subTo(Dest& dst) const - { - // This is the default implementation, - // derived class can reimplement it in a more optimized way. - typename Dest::PlainObject res(rows(),cols()); - evalTo(res); - dst -= res; - } - - /** \internal Don't use it, but do the equivalent: \code dst.applyOnTheRight(*this); \endcode */ - template inline void applyThisOnTheRight(Dest& dst) const - { - // This is the default implementation, - // derived class can reimplement it in a more optimized way. - dst = dst * this->derived(); - } - - /** \internal Don't use it, but do the equivalent: \code dst.applyOnTheLeft(*this); \endcode */ - template inline void applyThisOnTheLeft(Dest& dst) const - { - // This is the default implementation, - // derived class can reimplement it in a more optimized way. - dst = this->derived() * dst; - } - -}; - -/*************************************************************************** -* Implementation of matrix base methods -***************************************************************************/ - -/** \brief Copies the generic expression \a other into *this. - * - * \details The expression must provide a (templated) evalTo(Derived& dst) const - * function which does the actual job. In practice, this allows any user to write - * its own special matrix without having to modify MatrixBase - * - * \returns a reference to *this. - */ -template -template -Derived& DenseBase::operator=(const EigenBase &other) -{ - other.derived().evalTo(derived()); - return derived(); -} - -template -template -Derived& DenseBase::operator+=(const EigenBase &other) -{ - other.derived().addTo(derived()); - return derived(); -} - -template -template -Derived& DenseBase::operator-=(const EigenBase &other) -{ - other.derived().subTo(derived()); - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_EIGENBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Flagged.h b/modules/algebra/include/eigen3/Eigen/src/Core/Flagged.h deleted file mode 100644 index 2df0d2bd22..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Flagged.h +++ /dev/null @@ -1,140 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_FLAGGED_H -#define IMP_EIGEN_FLAGGED_H - -namespace IMP_Eigen { - -/** \class Flagged - * \ingroup Core_Module - * - * \brief Expression with modified flags - * - * \param ExpressionType the type of the object of which we are modifying the flags - * \param Added the flags added to the expression - * \param Removed the flags removed from the expression (has priority over Added). - * - * This class represents an expression whose flags have been modified. - * It is the return type of MatrixBase::flagged() - * and most of the time this is the only way it is used. - * - * \sa MatrixBase::flagged() - */ - -namespace internal { -template -struct traits > : traits -{ - enum { Flags = (ExpressionType::Flags | Added) & ~Removed }; -}; -} - -template class Flagged - : public MatrixBase > -{ - public: - - typedef MatrixBase Base; - - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Flagged) - typedef typename internal::conditional::ret, - ExpressionType, const ExpressionType&>::type ExpressionTypeNested; - typedef typename ExpressionType::InnerIterator InnerIterator; - - inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {} - - inline Index rows() const { return m_matrix.rows(); } - inline Index cols() const { return m_matrix.cols(); } - inline Index outerStride() const { return m_matrix.outerStride(); } - inline Index innerStride() const { return m_matrix.innerStride(); } - - inline CoeffReturnType coeff(Index row, Index col) const - { - return m_matrix.coeff(row, col); - } - - inline CoeffReturnType coeff(Index index) const - { - return m_matrix.coeff(index); - } - - inline const Scalar& coeffRef(Index row, Index col) const - { - return m_matrix.const_cast_derived().coeffRef(row, col); - } - - inline const Scalar& coeffRef(Index index) const - { - return m_matrix.const_cast_derived().coeffRef(index); - } - - inline Scalar& coeffRef(Index row, Index col) - { - return m_matrix.const_cast_derived().coeffRef(row, col); - } - - inline Scalar& coeffRef(Index index) - { - return m_matrix.const_cast_derived().coeffRef(index); - } - - template - inline const PacketScalar packet(Index row, Index col) const - { - return m_matrix.template packet(row, col); - } - - template - inline void writePacket(Index row, Index col, const PacketScalar& x) - { - m_matrix.const_cast_derived().template writePacket(row, col, x); - } - - template - inline const PacketScalar packet(Index index) const - { - return m_matrix.template packet(index); - } - - template - inline void writePacket(Index index, const PacketScalar& x) - { - m_matrix.const_cast_derived().template writePacket(index, x); - } - - const ExpressionType& _expression() const { return m_matrix; } - - template - typename ExpressionType::PlainObject solveTriangular(const MatrixBase& other) const; - - template - void solveTriangularInPlace(const MatrixBase& other) const; - - protected: - ExpressionTypeNested m_matrix; -}; - -/** \returns an expression of *this with added and removed flags - * - * This is mostly for internal use. - * - * \sa class Flagged - */ -template -template -inline const Flagged -DenseBase::flagged() const -{ - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_FLAGGED_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/ForceAlignedAccess.h b/modules/algebra/include/eigen3/Eigen/src/Core/ForceAlignedAccess.h deleted file mode 100644 index 7efdb263d2..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/ForceAlignedAccess.h +++ /dev/null @@ -1,146 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_FORCEALIGNEDACCESS_H -#define IMP_EIGEN_FORCEALIGNEDACCESS_H - -namespace IMP_Eigen { - -/** \class ForceAlignedAccess - * \ingroup Core_Module - * - * \brief Enforce aligned packet loads and stores regardless of what is requested - * - * \param ExpressionType the type of the object of which we are forcing aligned packet access - * - * This class is the return type of MatrixBase::forceAlignedAccess() - * and most of the time this is the only way it is used. - * - * \sa MatrixBase::forceAlignedAccess() - */ - -namespace internal { -template -struct traits > : public traits -{}; -} - -template class ForceAlignedAccess - : public internal::dense_xpr_base< ForceAlignedAccess >::type -{ - public: - - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess) - - inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {} - - inline Index rows() const { return m_expression.rows(); } - inline Index cols() const { return m_expression.cols(); } - inline Index outerStride() const { return m_expression.outerStride(); } - inline Index innerStride() const { return m_expression.innerStride(); } - - inline const CoeffReturnType coeff(Index row, Index col) const - { - return m_expression.coeff(row, col); - } - - inline Scalar& coeffRef(Index row, Index col) - { - return m_expression.const_cast_derived().coeffRef(row, col); - } - - inline const CoeffReturnType coeff(Index index) const - { - return m_expression.coeff(index); - } - - inline Scalar& coeffRef(Index index) - { - return m_expression.const_cast_derived().coeffRef(index); - } - - template - inline const PacketScalar packet(Index row, Index col) const - { - return m_expression.template packet(row, col); - } - - template - inline void writePacket(Index row, Index col, const PacketScalar& x) - { - m_expression.const_cast_derived().template writePacket(row, col, x); - } - - template - inline const PacketScalar packet(Index index) const - { - return m_expression.template packet(index); - } - - template - inline void writePacket(Index index, const PacketScalar& x) - { - m_expression.const_cast_derived().template writePacket(index, x); - } - - operator const ExpressionType&() const { return m_expression; } - - protected: - const ExpressionType& m_expression; - - private: - ForceAlignedAccess& operator=(const ForceAlignedAccess&); -}; - -/** \returns an expression of *this with forced aligned access - * \sa forceAlignedAccessIf(),class ForceAlignedAccess - */ -template -inline const ForceAlignedAccess -MatrixBase::forceAlignedAccess() const -{ - return ForceAlignedAccess(derived()); -} - -/** \returns an expression of *this with forced aligned access - * \sa forceAlignedAccessIf(), class ForceAlignedAccess - */ -template -inline ForceAlignedAccess -MatrixBase::forceAlignedAccess() -{ - return ForceAlignedAccess(derived()); -} - -/** \returns an expression of *this with forced aligned access if \a Enable is true. - * \sa forceAlignedAccess(), class ForceAlignedAccess - */ -template -template -inline typename internal::add_const_on_value_type,Derived&>::type>::type -MatrixBase::forceAlignedAccessIf() const -{ - return derived(); -} - -/** \returns an expression of *this with forced aligned access if \a Enable is true. - * \sa forceAlignedAccess(), class ForceAlignedAccess - */ -template -template -inline typename internal::conditional,Derived&>::type -MatrixBase::forceAlignedAccessIf() -{ - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_FORCEALIGNEDACCESS_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Functors.h b/modules/algebra/include/eigen3/Eigen/src/Core/Functors.h deleted file mode 100644 index b415e63a62..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Functors.h +++ /dev/null @@ -1,1029 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_FUNCTORS_H -#define IMP_EIGEN_FUNCTORS_H - -namespace IMP_Eigen { - -namespace internal { - -// associative functors: - -/** \internal - * \brief Template functor to compute the sum of two scalars - * - * \sa class CwiseBinaryOp, MatrixBase::operator+, class VectorwiseOp, MatrixBase::sum() - */ -template struct scalar_sum_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_sum_op) - IMP_EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a + b; } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return internal::padd(a,b); } - template - IMP_EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const - { return internal::predux(a); } -}; -template -struct functor_traits > { - enum { - Cost = NumTraits::AddCost, - PacketAccess = packet_traits::HasAdd - }; -}; - -/** \internal - * \brief Template functor to compute the product of two scalars - * - * \sa class CwiseBinaryOp, Cwise::operator*(), class VectorwiseOp, MatrixBase::redux() - */ -template struct scalar_product_op { - enum { - // TODO vectorize mixed product - Vectorizable = is_same::value && packet_traits::HasMul && packet_traits::HasMul - }; - typedef typename scalar_product_traits::ReturnType result_type; - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_product_op) - IMP_EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a * b; } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return internal::pmul(a,b); } - template - IMP_EIGEN_STRONG_INLINE const result_type predux(const Packet& a) const - { return internal::predux_mul(a); } -}; -template -struct functor_traits > { - enum { - Cost = (NumTraits::MulCost + NumTraits::MulCost)/2, // rough estimate! - PacketAccess = scalar_product_op::Vectorizable - }; -}; - -/** \internal - * \brief Template functor to compute the conjugate product of two scalars - * - * This is a short cut for conj(x) * y which is needed for optimization purpose; in Eigen2 support mode, this becomes x * conj(y) - */ -template struct scalar_conj_product_op { - - enum { - Conj = NumTraits::IsComplex - }; - - typedef typename scalar_product_traits::ReturnType result_type; - - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_conj_product_op) - IMP_EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const - { return conj_helper().pmul(a,b); } - - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return conj_helper().pmul(a,b); } -}; -template -struct functor_traits > { - enum { - Cost = NumTraits::MulCost, - PacketAccess = internal::is_same::value && packet_traits::HasMul - }; -}; - -/** \internal - * \brief Template functor to compute the min of two scalars - * - * \sa class CwiseBinaryOp, MatrixBase::cwiseMin, class VectorwiseOp, MatrixBase::minCoeff() - */ -template struct scalar_min_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_min_op) - IMP_EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { using std::min; return (min)(a, b); } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return internal::pmin(a,b); } - template - IMP_EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const - { return internal::predux_min(a); } -}; -template -struct functor_traits > { - enum { - Cost = NumTraits::AddCost, - PacketAccess = packet_traits::HasMin - }; -}; - -/** \internal - * \brief Template functor to compute the max of two scalars - * - * \sa class CwiseBinaryOp, MatrixBase::cwiseMax, class VectorwiseOp, MatrixBase::maxCoeff() - */ -template struct scalar_max_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op) - IMP_EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { using std::max; return (max)(a, b); } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return internal::pmax(a,b); } - template - IMP_EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const - { return internal::predux_max(a); } -}; -template -struct functor_traits > { - enum { - Cost = NumTraits::AddCost, - PacketAccess = packet_traits::HasMax - }; -}; - -/** \internal - * \brief Template functor to compute the hypot of two scalars - * - * \sa MatrixBase::stableNorm(), class Redux - */ -template struct scalar_hypot_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_hypot_op) -// typedef typename NumTraits::Real result_type; - IMP_EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& _x, const Scalar& _y) const - { - using std::max; - using std::min; - using std::sqrt; - Scalar p = (max)(_x, _y); - Scalar q = (min)(_x, _y); - Scalar qp = q/p; - return p * sqrt(Scalar(1) + qp*qp); - } -}; -template -struct functor_traits > { - enum { Cost = 5 * NumTraits::MulCost, PacketAccess=0 }; -}; - -/** \internal - * \brief Template functor to compute the pow of two scalars - */ -template struct scalar_binary_pow_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_binary_pow_op) - inline Scalar operator() (const Scalar& a, const OtherScalar& b) const { return numext::pow(a, b); } -}; -template -struct functor_traits > { - enum { Cost = 5 * NumTraits::MulCost, PacketAccess = false }; -}; - -// other binary functors: - -/** \internal - * \brief Template functor to compute the difference of two scalars - * - * \sa class CwiseBinaryOp, MatrixBase::operator- - */ -template struct scalar_difference_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_difference_op) - IMP_EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a - b; } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return internal::psub(a,b); } -}; -template -struct functor_traits > { - enum { - Cost = NumTraits::AddCost, - PacketAccess = packet_traits::HasSub - }; -}; - -/** \internal - * \brief Template functor to compute the quotient of two scalars - * - * \sa class CwiseBinaryOp, Cwise::operator/() - */ -template struct scalar_quotient_op { - enum { - // TODO vectorize mixed product - Vectorizable = is_same::value && packet_traits::HasDiv && packet_traits::HasDiv - }; - typedef typename scalar_product_traits::ReturnType result_type; - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_quotient_op) - IMP_EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a / b; } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const - { return internal::pdiv(a,b); } -}; -template -struct functor_traits > { - enum { - Cost = (NumTraits::MulCost + NumTraits::MulCost), // rough estimate! - PacketAccess = scalar_quotient_op::Vectorizable - }; -}; - - - -/** \internal - * \brief Template functor to compute the and of two booleans - * - * \sa class CwiseBinaryOp, ArrayBase::operator&& - */ -struct scalar_boolean_and_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_and_op) - IMP_EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a && b; } -}; -template<> struct functor_traits { - enum { - Cost = NumTraits::AddCost, - PacketAccess = false - }; -}; - -/** \internal - * \brief Template functor to compute the or of two booleans - * - * \sa class CwiseBinaryOp, ArrayBase::operator|| - */ -struct scalar_boolean_or_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_or_op) - IMP_EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a || b; } -}; -template<> struct functor_traits { - enum { - Cost = NumTraits::AddCost, - PacketAccess = false - }; -}; - -/** \internal - * \brief Template functors for comparison of two scalars - * \todo Implement packet-comparisons - */ -template struct scalar_cmp_op; - -template -struct functor_traits > { - enum { - Cost = NumTraits::AddCost, - PacketAccess = false - }; -}; - -template -struct result_of(Scalar,Scalar)> { - typedef bool type; -}; - - -template struct scalar_cmp_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op) - IMP_EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a==b;} -}; -template struct scalar_cmp_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op) - IMP_EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a struct scalar_cmp_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op) - IMP_EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a<=b;} -}; -template struct scalar_cmp_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op) - IMP_EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return !(a<=b || b<=a);} -}; -template struct scalar_cmp_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op) - IMP_EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a!=b;} -}; - -// unary functors: - -/** \internal - * \brief Template functor to compute the opposite of a scalar - * - * \sa class CwiseUnaryOp, MatrixBase::operator- - */ -template struct scalar_opposite_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_opposite_op) - IMP_EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return -a; } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return internal::pnegate(a); } -}; -template -struct functor_traits > -{ enum { - Cost = NumTraits::AddCost, - PacketAccess = packet_traits::HasNegate }; -}; - -/** \internal - * \brief Template functor to compute the absolute value of a scalar - * - * \sa class CwiseUnaryOp, Cwise::abs - */ -template struct scalar_abs_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_abs_op) - typedef typename NumTraits::Real result_type; - IMP_EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { using std::abs; return abs(a); } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return internal::pabs(a); } -}; -template -struct functor_traits > -{ - enum { - Cost = NumTraits::AddCost, - PacketAccess = packet_traits::HasAbs - }; -}; - -/** \internal - * \brief Template functor to compute the squared absolute value of a scalar - * - * \sa class CwiseUnaryOp, Cwise::abs2 - */ -template struct scalar_abs2_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_abs2_op) - typedef typename NumTraits::Real result_type; - IMP_EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs2(a); } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return internal::pmul(a,a); } -}; -template -struct functor_traits > -{ enum { Cost = NumTraits::MulCost, PacketAccess = packet_traits::HasAbs2 }; }; - -/** \internal - * \brief Template functor to compute the conjugate of a complex value - * - * \sa class CwiseUnaryOp, MatrixBase::conjugate() - */ -template struct scalar_conjugate_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_conjugate_op) - IMP_EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { using numext::conj; return conj(a); } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pconj(a); } -}; -template -struct functor_traits > -{ - enum { - Cost = NumTraits::IsComplex ? NumTraits::AddCost : 0, - PacketAccess = packet_traits::HasConj - }; -}; - -/** \internal - * \brief Template functor to cast a scalar to another type - * - * \sa class CwiseUnaryOp, MatrixBase::cast() - */ -template -struct scalar_cast_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op) - typedef NewType result_type; - IMP_EIGEN_STRONG_INLINE const NewType operator() (const Scalar& a) const { return cast(a); } -}; -template -struct functor_traits > -{ enum { Cost = is_same::value ? 0 : NumTraits::AddCost, PacketAccess = false }; }; - -/** \internal - * \brief Template functor to extract the real part of a complex - * - * \sa class CwiseUnaryOp, MatrixBase::real() - */ -template -struct scalar_real_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_real_op) - typedef typename NumTraits::Real result_type; - IMP_EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::real(a); } -}; -template -struct functor_traits > -{ enum { Cost = 0, PacketAccess = false }; }; - -/** \internal - * \brief Template functor to extract the imaginary part of a complex - * - * \sa class CwiseUnaryOp, MatrixBase::imag() - */ -template -struct scalar_imag_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_op) - typedef typename NumTraits::Real result_type; - IMP_EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::imag(a); } -}; -template -struct functor_traits > -{ enum { Cost = 0, PacketAccess = false }; }; - -/** \internal - * \brief Template functor to extract the real part of a complex as a reference - * - * \sa class CwiseUnaryOp, MatrixBase::real() - */ -template -struct scalar_real_ref_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_real_ref_op) - typedef typename NumTraits::Real result_type; - IMP_EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::real_ref(*const_cast(&a)); } -}; -template -struct functor_traits > -{ enum { Cost = 0, PacketAccess = false }; }; - -/** \internal - * \brief Template functor to extract the imaginary part of a complex as a reference - * - * \sa class CwiseUnaryOp, MatrixBase::imag() - */ -template -struct scalar_imag_ref_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_ref_op) - typedef typename NumTraits::Real result_type; - IMP_EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::imag_ref(*const_cast(&a)); } -}; -template -struct functor_traits > -{ enum { Cost = 0, PacketAccess = false }; }; - -/** \internal - * - * \brief Template functor to compute the exponential of a scalar - * - * \sa class CwiseUnaryOp, Cwise::exp() - */ -template struct scalar_exp_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_exp_op) - inline const Scalar operator() (const Scalar& a) const { using std::exp; return exp(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::pexp(a); } -}; -template -struct functor_traits > -{ enum { Cost = 5 * NumTraits::MulCost, PacketAccess = packet_traits::HasExp }; }; - -/** \internal - * - * \brief Template functor to compute the logarithm of a scalar - * - * \sa class CwiseUnaryOp, Cwise::log() - */ -template struct scalar_log_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_log_op) - inline const Scalar operator() (const Scalar& a) const { using std::log; return log(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::plog(a); } -}; -template -struct functor_traits > -{ enum { Cost = 5 * NumTraits::MulCost, PacketAccess = packet_traits::HasLog }; }; - -/** \internal - * \brief Template functor to multiply a scalar by a fixed other one - * - * \sa class CwiseUnaryOp, MatrixBase::operator*, MatrixBase::operator/ - */ -/* NOTE why doing the pset1() in packetOp *is* an optimization ? - * indeed it seems better to declare m_other as a Packet and do the pset1() once - * in the constructor. However, in practice: - * - GCC does not like m_other as a Packet and generate a load every time it needs it - * - on the other hand GCC is able to moves the pset1() outside the loop :) - * - simpler code ;) - * (ICC and gcc 4.4 seems to perform well in both cases, the issue is visible with y = a*x + b*y) - */ -template -struct scalar_multiple_op { - typedef typename packet_traits::type Packet; - // FIXME default copy constructors seems bugged with std::complex<> - IMP_EIGEN_STRONG_INLINE scalar_multiple_op(const scalar_multiple_op& other) : m_other(other.m_other) { } - IMP_EIGEN_STRONG_INLINE scalar_multiple_op(const Scalar& other) : m_other(other) { } - IMP_EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a * m_other; } - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return internal::pmul(a, pset1(m_other)); } - typename add_const_on_value_type::Nested>::type m_other; -}; -template -struct functor_traits > -{ enum { Cost = NumTraits::MulCost, PacketAccess = packet_traits::HasMul }; }; - -template -struct scalar_multiple2_op { - typedef typename scalar_product_traits::ReturnType result_type; - IMP_EIGEN_STRONG_INLINE scalar_multiple2_op(const scalar_multiple2_op& other) : m_other(other.m_other) { } - IMP_EIGEN_STRONG_INLINE scalar_multiple2_op(const Scalar2& other) : m_other(other) { } - IMP_EIGEN_STRONG_INLINE result_type operator() (const Scalar1& a) const { return a * m_other; } - typename add_const_on_value_type::Nested>::type m_other; -}; -template -struct functor_traits > -{ enum { Cost = NumTraits::MulCost, PacketAccess = false }; }; - -/** \internal - * \brief Template functor to divide a scalar by a fixed other one - * - * This functor is used to implement the quotient of a matrix by - * a scalar where the scalar type is not necessarily a floating point type. - * - * \sa class CwiseUnaryOp, MatrixBase::operator/ - */ -template -struct scalar_quotient1_op { - typedef typename packet_traits::type Packet; - // FIXME default copy constructors seems bugged with std::complex<> - IMP_EIGEN_STRONG_INLINE scalar_quotient1_op(const scalar_quotient1_op& other) : m_other(other.m_other) { } - IMP_EIGEN_STRONG_INLINE scalar_quotient1_op(const Scalar& other) : m_other(other) {} - IMP_EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a / m_other; } - IMP_EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const - { return internal::pdiv(a, pset1(m_other)); } - typename add_const_on_value_type::Nested>::type m_other; -}; -template -struct functor_traits > -{ enum { Cost = 2 * NumTraits::MulCost, PacketAccess = packet_traits::HasDiv }; }; - -// nullary functors - -template -struct scalar_constant_op { - typedef typename packet_traits::type Packet; - IMP_EIGEN_STRONG_INLINE scalar_constant_op(const scalar_constant_op& other) : m_other(other.m_other) { } - IMP_EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) { } - template - IMP_EIGEN_STRONG_INLINE const Scalar operator() (Index, Index = 0) const { return m_other; } - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(Index, Index = 0) const { return internal::pset1(m_other); } - const Scalar m_other; -}; -template -struct functor_traits > -// FIXME replace this packet test by a safe one -{ enum { Cost = 1, PacketAccess = packet_traits::Vectorizable, IsRepeatable = true }; }; - -template struct scalar_identity_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_identity_op) - template - IMP_EIGEN_STRONG_INLINE const Scalar operator() (Index row, Index col) const { return row==col ? Scalar(1) : Scalar(0); } -}; -template -struct functor_traits > -{ enum { Cost = NumTraits::AddCost, PacketAccess = false, IsRepeatable = true }; }; - -template struct linspaced_op_impl; - -// linear access for packet ops: -// 1) initialization -// base = [low, ..., low] + ([step, ..., step] * [-size, ..., 0]) -// 2) each step (where size is 1 for coeff access or PacketSize for packet access) -// base += [size*step, ..., size*step] -// -// TODO: Perhaps it's better to initialize lazily (so not in the constructor but in packetOp) -// in order to avoid the padd() in operator() ? -template -struct linspaced_op_impl -{ - typedef typename packet_traits::type Packet; - - linspaced_op_impl(const Scalar& low, const Scalar& step) : - m_low(low), m_step(step), - m_packetStep(pset1(packet_traits::size*step)), - m_base(padd(pset1(low), pmul(pset1(step),plset(-packet_traits::size)))) {} - - template - IMP_EIGEN_STRONG_INLINE const Scalar operator() (Index i) const - { - m_base = padd(m_base, pset1(m_step)); - return m_low+Scalar(i)*m_step; - } - - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(Index) const { return m_base = padd(m_base,m_packetStep); } - - const Scalar m_low; - const Scalar m_step; - const Packet m_packetStep; - mutable Packet m_base; -}; - -// random access for packet ops: -// 1) each step -// [low, ..., low] + ( [step, ..., step] * ( [i, ..., i] + [0, ..., size] ) ) -template -struct linspaced_op_impl -{ - typedef typename packet_traits::type Packet; - - linspaced_op_impl(const Scalar& low, const Scalar& step) : - m_low(low), m_step(step), - m_lowPacket(pset1(m_low)), m_stepPacket(pset1(m_step)), m_interPacket(plset(0)) {} - - template - IMP_EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return m_low+i*m_step; } - - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(Index i) const - { return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1(Scalar(i)),m_interPacket))); } - - const Scalar m_low; - const Scalar m_step; - const Packet m_lowPacket; - const Packet m_stepPacket; - const Packet m_interPacket; -}; - -// ----- Linspace functor ---------------------------------------------------------------- - -// Forward declaration (we default to random access which does not really give -// us a speed gain when using packet access but it allows to use the functor in -// nested expressions). -template struct linspaced_op; -template struct functor_traits< linspaced_op > -{ enum { Cost = 1, PacketAccess = packet_traits::HasSetLinear, IsRepeatable = true }; }; -template struct linspaced_op -{ - typedef typename packet_traits::type Packet; - linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1))) {} - - template - IMP_EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return impl(i); } - - // We need this function when assigning e.g. a RowVectorXd to a MatrixXd since - // there row==0 and col is used for the actual iteration. - template - IMP_EIGEN_STRONG_INLINE const Scalar operator() (Index row, Index col) const - { - imp_eigen_assert(col==0 || row==0); - return impl(col + row); - } - - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(Index i) const { return impl.packetOp(i); } - - // We need this function when assigning e.g. a RowVectorXd to a MatrixXd since - // there row==0 and col is used for the actual iteration. - template - IMP_EIGEN_STRONG_INLINE const Packet packetOp(Index row, Index col) const - { - imp_eigen_assert(col==0 || row==0); - return impl.packetOp(col + row); - } - - // This proxy object handles the actual required temporaries, the different - // implementations (random vs. sequential access) as well as the - // correct piping to size 2/4 packet operations. - const linspaced_op_impl impl; -}; - -// all functors allow linear access, except scalar_identity_op. So we fix here a quick meta -// to indicate whether a functor allows linear access, just always answering 'yes' except for -// scalar_identity_op. -// FIXME move this to functor_traits adding a functor_default -template struct functor_has_linear_access { enum { ret = 1 }; }; -template struct functor_has_linear_access > { enum { ret = 0 }; }; - -// In Eigen, any binary op (Product, CwiseBinaryOp) require the Lhs and Rhs to have the same scalar type, except for multiplication -// where the mixing of different types is handled by scalar_product_traits -// In particular, real * complex is allowed. -// FIXME move this to functor_traits adding a functor_default -template struct functor_is_product_like { enum { ret = 0 }; }; -template struct functor_is_product_like > { enum { ret = 1 }; }; -template struct functor_is_product_like > { enum { ret = 1 }; }; -template struct functor_is_product_like > { enum { ret = 1 }; }; - - -/** \internal - * \brief Template functor to add a scalar to a fixed other one - * \sa class CwiseUnaryOp, Array::operator+ - */ -/* If you wonder why doing the pset1() in packetOp() is an optimization check scalar_multiple_op */ -template -struct scalar_add_op { - typedef typename packet_traits::type Packet; - // FIXME default copy constructors seems bugged with std::complex<> - inline scalar_add_op(const scalar_add_op& other) : m_other(other.m_other) { } - inline scalar_add_op(const Scalar& other) : m_other(other) { } - inline Scalar operator() (const Scalar& a) const { return a + m_other; } - inline const Packet packetOp(const Packet& a) const - { return internal::padd(a, pset1(m_other)); } - const Scalar m_other; -}; -template -struct functor_traits > -{ enum { Cost = NumTraits::AddCost, PacketAccess = packet_traits::HasAdd }; }; - -/** \internal - * \brief Template functor to compute the square root of a scalar - * \sa class CwiseUnaryOp, Cwise::sqrt() - */ -template struct scalar_sqrt_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_sqrt_op) - inline const Scalar operator() (const Scalar& a) const { using std::sqrt; return sqrt(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); } -}; -template -struct functor_traits > -{ enum { - Cost = 5 * NumTraits::MulCost, - PacketAccess = packet_traits::HasSqrt - }; -}; - -/** \internal - * \brief Template functor to compute the cosine of a scalar - * \sa class CwiseUnaryOp, ArrayBase::cos() - */ -template struct scalar_cos_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cos_op) - inline Scalar operator() (const Scalar& a) const { using std::cos; return cos(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::pcos(a); } -}; -template -struct functor_traits > -{ - enum { - Cost = 5 * NumTraits::MulCost, - PacketAccess = packet_traits::HasCos - }; -}; - -/** \internal - * \brief Template functor to compute the sine of a scalar - * \sa class CwiseUnaryOp, ArrayBase::sin() - */ -template struct scalar_sin_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_sin_op) - inline const Scalar operator() (const Scalar& a) const { using std::sin; return sin(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::psin(a); } -}; -template -struct functor_traits > -{ - enum { - Cost = 5 * NumTraits::MulCost, - PacketAccess = packet_traits::HasSin - }; -}; - - -/** \internal - * \brief Template functor to compute the tan of a scalar - * \sa class CwiseUnaryOp, ArrayBase::tan() - */ -template struct scalar_tan_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_tan_op) - inline const Scalar operator() (const Scalar& a) const { using std::tan; return tan(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::ptan(a); } -}; -template -struct functor_traits > -{ - enum { - Cost = 5 * NumTraits::MulCost, - PacketAccess = packet_traits::HasTan - }; -}; - -/** \internal - * \brief Template functor to compute the arc cosine of a scalar - * \sa class CwiseUnaryOp, ArrayBase::acos() - */ -template struct scalar_acos_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_acos_op) - inline const Scalar operator() (const Scalar& a) const { using std::acos; return acos(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::pacos(a); } -}; -template -struct functor_traits > -{ - enum { - Cost = 5 * NumTraits::MulCost, - PacketAccess = packet_traits::HasACos - }; -}; - -/** \internal - * \brief Template functor to compute the arc sine of a scalar - * \sa class CwiseUnaryOp, ArrayBase::asin() - */ -template struct scalar_asin_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_asin_op) - inline const Scalar operator() (const Scalar& a) const { using std::asin; return asin(a); } - typedef typename packet_traits::type Packet; - inline Packet packetOp(const Packet& a) const { return internal::pasin(a); } -}; -template -struct functor_traits > -{ - enum { - Cost = 5 * NumTraits::MulCost, - PacketAccess = packet_traits::HasASin - }; -}; - -/** \internal - * \brief Template functor to raise a scalar to a power - * \sa class CwiseUnaryOp, Cwise::pow - */ -template -struct scalar_pow_op { - // FIXME default copy constructors seems bugged with std::complex<> - inline scalar_pow_op(const scalar_pow_op& other) : m_exponent(other.m_exponent) { } - inline scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {} - inline Scalar operator() (const Scalar& a) const { return numext::pow(a, m_exponent); } - const Scalar m_exponent; -}; -template -struct functor_traits > -{ enum { Cost = 5 * NumTraits::MulCost, PacketAccess = false }; }; - -/** \internal - * \brief Template functor to compute the quotient between a scalar and array entries. - * \sa class CwiseUnaryOp, Cwise::inverse() - */ -template -struct scalar_inverse_mult_op { - scalar_inverse_mult_op(const Scalar& other) : m_other(other) {} - inline Scalar operator() (const Scalar& a) const { return m_other / a; } - template - inline const Packet packetOp(const Packet& a) const - { return internal::pdiv(pset1(m_other),a); } - Scalar m_other; -}; - -/** \internal - * \brief Template functor to compute the inverse of a scalar - * \sa class CwiseUnaryOp, Cwise::inverse() - */ -template -struct scalar_inverse_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_inverse_op) - inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; } - template - inline const Packet packetOp(const Packet& a) const - { return internal::pdiv(pset1(Scalar(1)),a); } -}; -template -struct functor_traits > -{ enum { Cost = NumTraits::MulCost, PacketAccess = packet_traits::HasDiv }; }; - -/** \internal - * \brief Template functor to compute the square of a scalar - * \sa class CwiseUnaryOp, Cwise::square() - */ -template -struct scalar_square_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_square_op) - inline Scalar operator() (const Scalar& a) const { return a*a; } - template - inline const Packet packetOp(const Packet& a) const - { return internal::pmul(a,a); } -}; -template -struct functor_traits > -{ enum { Cost = NumTraits::MulCost, PacketAccess = packet_traits::HasMul }; }; - -/** \internal - * \brief Template functor to compute the cube of a scalar - * \sa class CwiseUnaryOp, Cwise::cube() - */ -template -struct scalar_cube_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_cube_op) - inline Scalar operator() (const Scalar& a) const { return a*a*a; } - template - inline const Packet packetOp(const Packet& a) const - { return internal::pmul(a,pmul(a,a)); } -}; -template -struct functor_traits > -{ enum { Cost = 2*NumTraits::MulCost, PacketAccess = packet_traits::HasMul }; }; - -// default functor traits for STL functors: - -template -struct functor_traits > -{ enum { Cost = NumTraits::MulCost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = NumTraits::MulCost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = NumTraits::AddCost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = NumTraits::AddCost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = NumTraits::AddCost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1, PacketAccess = false }; }; - -#if(__cplusplus < 201103L) -// std::binder* are deprecated since c++11 and will be removed in c++17 -template -struct functor_traits > -{ enum { Cost = functor_traits::Cost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = functor_traits::Cost, PacketAccess = false }; }; -#endif - -template -struct functor_traits > -{ enum { Cost = 1 + functor_traits::Cost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 1 + functor_traits::Cost, PacketAccess = false }; }; - -#ifdef IMP_EIGEN_STDEXT_SUPPORT - -template -struct functor_traits > -{ enum { Cost = 0, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = 0, PacketAccess = false }; }; - -template -struct functor_traits > > -{ enum { Cost = 0, PacketAccess = false }; }; - -template -struct functor_traits > > -{ enum { Cost = 0, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = functor_traits::Cost + functor_traits::Cost, PacketAccess = false }; }; - -template -struct functor_traits > -{ enum { Cost = functor_traits::Cost + functor_traits::Cost + functor_traits::Cost, PacketAccess = false }; }; - -#endif // IMP_EIGEN_STDEXT_SUPPORT - -// allow to add new functors and specializations of functor_traits from outside Eigen. -// this macro is really needed because functor_traits must be specialized after it is declared but before it is used... -#ifdef IMP_EIGEN_FUNCTORS_PLUGIN -#include IMP_EIGEN_FUNCTORS_PLUGIN -#endif - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_FUNCTORS_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Fuzzy.h b/modules/algebra/include/eigen3/Eigen/src/Core/Fuzzy.h deleted file mode 100644 index 1842ad7e38..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Fuzzy.h +++ /dev/null @@ -1,150 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2008 Benoit Jacob -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_FUZZY_H -#define IMP_EIGEN_FUZZY_H - -namespace IMP_Eigen { - -namespace internal -{ - -template::IsInteger> -struct isApprox_selector -{ - static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec) - { - using std::min; - typename internal::nested::type nested(x); - typename internal::nested::type otherNested(y); - return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * (min)(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum()); - } -}; - -template -struct isApprox_selector -{ - static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar&) - { - return x.matrix() == y.matrix(); - } -}; - -template::IsInteger> -struct isMuchSmallerThan_object_selector -{ - static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec) - { - return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum(); - } -}; - -template -struct isMuchSmallerThan_object_selector -{ - static bool run(const Derived& x, const OtherDerived&, const typename Derived::RealScalar&) - { - return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix(); - } -}; - -template::IsInteger> -struct isMuchSmallerThan_scalar_selector -{ - static bool run(const Derived& x, const typename Derived::RealScalar& y, const typename Derived::RealScalar& prec) - { - return x.cwiseAbs2().sum() <= numext::abs2(prec * y); - } -}; - -template -struct isMuchSmallerThan_scalar_selector -{ - static bool run(const Derived& x, const typename Derived::RealScalar&, const typename Derived::RealScalar&) - { - return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix(); - } -}; - -} // end namespace internal - - -/** \returns \c true if \c *this is approximately equal to \a other, within the precision - * determined by \a prec. - * - * \note The fuzzy compares are done multiplicatively. Two vectors \f$ v \f$ and \f$ w \f$ - * are considered to be approximately equal within precision \f$ p \f$ if - * \f[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \f] - * For matrices, the comparison is done using the Hilbert-Schmidt norm (aka Frobenius norm - * L2 norm). - * - * \note Because of the multiplicativeness of this comparison, one can't use this function - * to check whether \c *this is approximately equal to the zero matrix or vector. - * Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix - * or vector. If you want to test whether \c *this is zero, use internal::isMuchSmallerThan(const - * RealScalar&, RealScalar) instead. - * - * \sa internal::isMuchSmallerThan(const RealScalar&, RealScalar) const - */ -template -template -bool DenseBase::isApprox( - const DenseBase& other, - const RealScalar& prec -) const -{ - return internal::isApprox_selector::run(derived(), other.derived(), prec); -} - -/** \returns \c true if the norm of \c *this is much smaller than \a other, - * within the precision determined by \a prec. - * - * \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is - * considered to be much smaller than \f$ x \f$ within precision \f$ p \f$ if - * \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f] - * - * For matrices, the comparison is done using the Hilbert-Schmidt norm. For this reason, - * the value of the reference scalar \a other should come from the Hilbert-Schmidt norm - * of a reference matrix of same dimensions. - * - * \sa isApprox(), isMuchSmallerThan(const DenseBase&, RealScalar) const - */ -template -bool DenseBase::isMuchSmallerThan( - const typename NumTraits::Real& other, - const RealScalar& prec -) const -{ - return internal::isMuchSmallerThan_scalar_selector::run(derived(), other, prec); -} - -/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other, - * within the precision determined by \a prec. - * - * \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is - * considered to be much smaller than a vector \f$ w \f$ within precision \f$ p \f$ if - * \f[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \f] - * For matrices, the comparison is done using the Hilbert-Schmidt norm. - * - * \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const - */ -template -template -bool DenseBase::isMuchSmallerThan( - const DenseBase& other, - const RealScalar& prec -) const -{ - return internal::isMuchSmallerThan_object_selector::run(derived(), other.derived(), prec); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_FUZZY_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/GeneralProduct.h b/modules/algebra/include/eigen3/Eigen/src/Core/GeneralProduct.h deleted file mode 100644 index f1fe729931..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/GeneralProduct.h +++ /dev/null @@ -1,633 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2008 Benoit Jacob -// Copyright (C) 2008-2011 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_GENERAL_PRODUCT_H -#define IMP_EIGEN_GENERAL_PRODUCT_H - -namespace IMP_Eigen { - -/** \class GeneralProduct - * \ingroup Core_Module - * - * \brief Expression of the product of two general matrices or vectors - * - * \param LhsNested the type used to store the left-hand side - * \param RhsNested the type used to store the right-hand side - * \param ProductMode the type of the product - * - * This class represents an expression of the product of two general matrices. - * We call a general matrix, a dense matrix with full storage. For instance, - * This excludes triangular, selfadjoint, and sparse matrices. - * It is the return type of the operator* between general matrices. Its template - * arguments are determined automatically by ProductReturnType. Therefore, - * GeneralProduct should never be used direclty. To determine the result type of a - * function which involves a matrix product, use ProductReturnType::Type. - * - * \sa ProductReturnType, MatrixBase::operator*(const MatrixBase&) - */ -template::value> -class GeneralProduct; - -enum { - Large = 2, - Small = 3 -}; - -namespace internal { - -template struct product_type_selector; - -template struct product_size_category -{ - enum { is_large = MaxSize == Dynamic || - Size >= IMP_EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD, - value = is_large ? Large - : Size == 1 ? 1 - : Small - }; -}; - -template struct product_type -{ - typedef typename remove_all::type _Lhs; - typedef typename remove_all::type _Rhs; - enum { - MaxRows = _Lhs::MaxRowsAtCompileTime, - Rows = _Lhs::RowsAtCompileTime, - MaxCols = _Rhs::MaxColsAtCompileTime, - Cols = _Rhs::ColsAtCompileTime, - MaxDepth = IMP_EIGEN_SIZE_MIN_PREFER_FIXED(_Lhs::MaxColsAtCompileTime, - _Rhs::MaxRowsAtCompileTime), - Depth = IMP_EIGEN_SIZE_MIN_PREFER_FIXED(_Lhs::ColsAtCompileTime, - _Rhs::RowsAtCompileTime), - LargeThreshold = IMP_EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD - }; - - // the splitting into different lines of code here, introducing the _select enums and the typedef below, - // is to work around an internal compiler error with gcc 4.1 and 4.2. -private: - enum { - rows_select = product_size_category::value, - cols_select = product_size_category::value, - depth_select = product_size_category::value - }; - typedef product_type_selector selector; - -public: - enum { - value = selector::ret - }; -#ifdef IMP_EIGEN_DEBUG_PRODUCT - static void debug() - { - IMP_EIGEN_DEBUG_VAR(Rows); - IMP_EIGEN_DEBUG_VAR(Cols); - IMP_EIGEN_DEBUG_VAR(Depth); - IMP_EIGEN_DEBUG_VAR(rows_select); - IMP_EIGEN_DEBUG_VAR(cols_select); - IMP_EIGEN_DEBUG_VAR(depth_select); - IMP_EIGEN_DEBUG_VAR(value); - } -#endif -}; - - -/* The following allows to select the kind of product at compile time - * based on the three dimensions of the product. - * This is a compile time mapping from {1,Small,Large}^3 -> {product types} */ -// FIXME I'm not sure the current mapping is the ideal one. -template struct product_type_selector { enum { ret = OuterProduct }; }; -template struct product_type_selector<1, 1, Depth> { enum { ret = InnerProduct }; }; -template<> struct product_type_selector<1, 1, 1> { enum { ret = InnerProduct }; }; -template<> struct product_type_selector { enum { ret = CoeffBasedProductMode }; }; -template<> struct product_type_selector<1, Small,Small> { enum { ret = CoeffBasedProductMode }; }; -template<> struct product_type_selector { enum { ret = CoeffBasedProductMode }; }; -template<> struct product_type_selector { enum { ret = LazyCoeffBasedProductMode }; }; -template<> struct product_type_selector { enum { ret = LazyCoeffBasedProductMode }; }; -template<> struct product_type_selector { enum { ret = LazyCoeffBasedProductMode }; }; -template<> struct product_type_selector<1, Large,Small> { enum { ret = CoeffBasedProductMode }; }; -template<> struct product_type_selector<1, Large,Large> { enum { ret = GemvProduct }; }; -template<> struct product_type_selector<1, Small,Large> { enum { ret = CoeffBasedProductMode }; }; -template<> struct product_type_selector { enum { ret = CoeffBasedProductMode }; }; -template<> struct product_type_selector { enum { ret = GemvProduct }; }; -template<> struct product_type_selector { enum { ret = CoeffBasedProductMode }; }; -template<> struct product_type_selector { enum { ret = GemmProduct }; }; -template<> struct product_type_selector { enum { ret = GemmProduct }; }; -template<> struct product_type_selector { enum { ret = GemmProduct }; }; -template<> struct product_type_selector { enum { ret = GemmProduct }; }; -template<> struct product_type_selector { enum { ret = GemmProduct }; }; -template<> struct product_type_selector { enum { ret = GemmProduct }; }; -template<> struct product_type_selector { enum { ret = GemmProduct }; }; - -} // end namespace internal - -/** \class ProductReturnType - * \ingroup Core_Module - * - * \brief Helper class to get the correct and optimized returned type of operator* - * - * \param Lhs the type of the left-hand side - * \param Rhs the type of the right-hand side - * \param ProductMode the type of the product (determined automatically by internal::product_mode) - * - * This class defines the typename Type representing the optimized product expression - * between two matrix expressions. In practice, using ProductReturnType::Type - * is the recommended way to define the result type of a function returning an expression - * which involve a matrix product. The class Product should never be - * used directly. - * - * \sa class Product, MatrixBase::operator*(const MatrixBase&) - */ -template -struct ProductReturnType -{ - // TODO use the nested type to reduce instanciations ???? -// typedef typename internal::nested::type LhsNested; -// typedef typename internal::nested::type RhsNested; - - typedef GeneralProduct Type; -}; - -template -struct ProductReturnType -{ - typedef typename internal::nested::type >::type LhsNested; - typedef typename internal::nested::type >::type RhsNested; - typedef CoeffBasedProduct Type; -}; - -template -struct ProductReturnType -{ - typedef typename internal::nested::type >::type LhsNested; - typedef typename internal::nested::type >::type RhsNested; - typedef CoeffBasedProduct Type; -}; - -// this is a workaround for sun CC -template -struct LazyProductReturnType : public ProductReturnType -{}; - -/*********************************************************************** -* Implementation of Inner Vector Vector Product -***********************************************************************/ - -// FIXME : maybe the "inner product" could return a Scalar -// instead of a 1x1 matrix ?? -// Pro: more natural for the user -// Cons: this could be a problem if in a meta unrolled algorithm a matrix-matrix -// product ends up to a row-vector times col-vector product... To tackle this use -// case, we could have a specialization for Block with: operator=(Scalar x); - -namespace internal { - -template -struct traits > - : traits::ReturnType,1,1> > -{}; - -} - -template -class GeneralProduct - : internal::no_assignment_operator, - public Matrix::ReturnType,1,1> -{ - typedef Matrix::ReturnType,1,1> Base; - public: - GeneralProduct(const Lhs& lhs, const Rhs& rhs) - { - Base::coeffRef(0,0) = (lhs.transpose().cwiseProduct(rhs)).sum(); - } - - /** Convertion to scalar */ - operator const typename Base::Scalar() const { - return Base::coeff(0,0); - } -}; - -/*********************************************************************** -* Implementation of Outer Vector Vector Product -***********************************************************************/ - -namespace internal { - -// Column major -template -IMP_EIGEN_DONT_INLINE void outer_product_selector_run(const ProductType& prod, Dest& dest, const Func& func, const false_type&) -{ - typedef typename Dest::Index Index; - // FIXME make sure lhs is sequentially stored - // FIXME not very good if rhs is real and lhs complex while alpha is real too - const Index cols = dest.cols(); - for (Index j=0; j -IMP_EIGEN_DONT_INLINE void outer_product_selector_run(const ProductType& prod, Dest& dest, const Func& func, const true_type&) { - typedef typename Dest::Index Index; - // FIXME make sure rhs is sequentially stored - // FIXME not very good if lhs is real and rhs complex while alpha is real too - const Index rows = dest.rows(); - for (Index i=0; i -struct traits > - : traits, Lhs, Rhs> > -{}; - -} - -template -class GeneralProduct - : public ProductBase, Lhs, Rhs> -{ - template struct is_row_major : internal::conditional<(int(T::Flags)&RowMajorBit), internal::true_type, internal::false_type>::type {}; - - public: - IMP_EIGEN_PRODUCT_PUBLIC_INTERFACE(GeneralProduct) - - GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) - { - } - - struct set { template void operator()(const Dst& dst, const Src& src) const { dst.const_cast_derived() = src; } }; - struct add { template void operator()(const Dst& dst, const Src& src) const { dst.const_cast_derived() += src; } }; - struct sub { template void operator()(const Dst& dst, const Src& src) const { dst.const_cast_derived() -= src; } }; - struct adds { - Scalar m_scale; - adds(const Scalar& s) : m_scale(s) {} - template void operator()(const Dst& dst, const Src& src) const { - dst.const_cast_derived() += m_scale * src; - } - }; - - template - inline void evalTo(Dest& dest) const { - internal::outer_product_selector_run(*this, dest, set(), is_row_major()); - } - - template - inline void addTo(Dest& dest) const { - internal::outer_product_selector_run(*this, dest, add(), is_row_major()); - } - - template - inline void subTo(Dest& dest) const { - internal::outer_product_selector_run(*this, dest, sub(), is_row_major()); - } - - template void scaleAndAddTo(Dest& dest, const Scalar& alpha) const - { - internal::outer_product_selector_run(*this, dest, adds(alpha), is_row_major()); - } -}; - -/*********************************************************************** -* Implementation of General Matrix Vector Product -***********************************************************************/ - -/* According to the shape/flags of the matrix we have to distinghish 3 different cases: - * 1 - the matrix is col-major, BLAS compatible and M is large => call fast BLAS-like colmajor routine - * 2 - the matrix is row-major, BLAS compatible and N is large => call fast BLAS-like rowmajor routine - * 3 - all other cases are handled using a simple loop along the outer-storage direction. - * Therefore we need a lower level meta selector. - * Furthermore, if the matrix is the rhs, then the product has to be transposed. - */ -namespace internal { - -template -struct traits > - : traits, Lhs, Rhs> > -{}; - -template -struct gemv_selector; - -} // end namespace internal - -template -class GeneralProduct - : public ProductBase, Lhs, Rhs> -{ - public: - IMP_EIGEN_PRODUCT_PUBLIC_INTERFACE(GeneralProduct) - - typedef typename Lhs::Scalar LhsScalar; - typedef typename Rhs::Scalar RhsScalar; - - GeneralProduct(const Lhs& a_lhs, const Rhs& a_rhs) : Base(a_lhs,a_rhs) - { -// IMP_EIGEN_STATIC_ASSERT((internal::is_same::value), -// YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - } - - enum { Side = Lhs::IsVectorAtCompileTime ? OnTheLeft : OnTheRight }; - typedef typename internal::conditional::type MatrixType; - - template void scaleAndAddTo(Dest& dst, const Scalar& alpha) const - { - imp_eigen_assert(m_lhs.rows() == dst.rows() && m_rhs.cols() == dst.cols()); - internal::gemv_selector::HasUsableDirectAccess)>::run(*this, dst, alpha); - } -}; - -namespace internal { - -// The vector is on the left => transposition -template -struct gemv_selector -{ - template - static void run(const ProductType& prod, Dest& dest, const typename ProductType::Scalar& alpha) - { - Transpose destT(dest); - enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor }; - gemv_selector - ::run(GeneralProduct,Transpose, GemvProduct> - (prod.rhs().transpose(), prod.lhs().transpose()), destT, alpha); - } -}; - -template struct gemv_static_vector_if; - -template -struct gemv_static_vector_if -{ - IMP_EIGEN_STRONG_INLINE Scalar* data() { imp_eigen_internal_assert(false && "should never be called"); return 0; } -}; - -template -struct gemv_static_vector_if -{ - IMP_EIGEN_STRONG_INLINE Scalar* data() { return 0; } -}; - -template -struct gemv_static_vector_if -{ - #if IMP_EIGEN_ALIGN_STATICALLY - internal::plain_array m_data; - IMP_EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; } - #else - // Some architectures cannot align on the stack, - // => let's manually enforce alignment by allocating more data and return the address of the first aligned element. - enum { - ForceAlignment = internal::packet_traits::Vectorizable, - PacketSize = internal::packet_traits::size - }; - internal::plain_array m_data; - IMP_EIGEN_STRONG_INLINE Scalar* data() { - return ForceAlignment - ? reinterpret_cast((reinterpret_cast(m_data.array) & ~(size_t(15))) + 16) - : m_data.array; - } - #endif -}; - -template<> struct gemv_selector -{ - template - static inline void run(const ProductType& prod, Dest& dest, const typename ProductType::Scalar& alpha) - { - typedef typename ProductType::Index Index; - typedef typename ProductType::LhsScalar LhsScalar; - typedef typename ProductType::RhsScalar RhsScalar; - typedef typename ProductType::Scalar ResScalar; - typedef typename ProductType::RealScalar RealScalar; - typedef typename ProductType::ActualLhsType ActualLhsType; - typedef typename ProductType::ActualRhsType ActualRhsType; - typedef typename ProductType::LhsBlasTraits LhsBlasTraits; - typedef typename ProductType::RhsBlasTraits RhsBlasTraits; - typedef Map, Aligned> MappedDest; - - ActualLhsType actualLhs = LhsBlasTraits::extract(prod.lhs()); - ActualRhsType actualRhs = RhsBlasTraits::extract(prod.rhs()); - - ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs()) - * RhsBlasTraits::extractScalarFactor(prod.rhs()); - - // make sure Dest is a compile-time vector type (bug 1166) - typedef typename conditional::type ActualDest; - - enum { - // FIXME find a way to allow an inner stride on the result if packet_traits::size==1 - // on, the other hand it is good for the cache to pack the vector anyways... - EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime==1), - ComplexByReal = (NumTraits::IsComplex) && (!NumTraits::IsComplex), - MightCannotUseDest = (ActualDest::InnerStrideAtCompileTime!=1) || ComplexByReal - }; - - gemv_static_vector_if static_dest; - - bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0)); - bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible; - - RhsScalar compatibleAlpha = get_factor::run(actualAlpha); - - imp_ei_declare_aligned_stack_constructed_variable(ResScalar,actualDestPtr,dest.size(), - evalToDest ? dest.data() : static_dest.data()); - - if(!evalToDest) - { - #ifdef IMP_EIGEN_DENSE_STORAGE_CTOR_PLUGIN - int size = dest.size(); - IMP_EIGEN_DENSE_STORAGE_CTOR_PLUGIN - #endif - if(!alphaIsCompatible) - { - MappedDest(actualDestPtr, dest.size()).setZero(); - compatibleAlpha = RhsScalar(1); - } - else - MappedDest(actualDestPtr, dest.size()) = dest; - } - - general_matrix_vector_product - ::run( - actualLhs.rows(), actualLhs.cols(), - actualLhs.data(), actualLhs.outerStride(), - actualRhs.data(), actualRhs.innerStride(), - actualDestPtr, 1, - compatibleAlpha); - - if (!evalToDest) - { - if(!alphaIsCompatible) - dest += actualAlpha * MappedDest(actualDestPtr, dest.size()); - else - dest = MappedDest(actualDestPtr, dest.size()); - } - } -}; - -template<> struct gemv_selector -{ - template - static void run(const ProductType& prod, Dest& dest, const typename ProductType::Scalar& alpha) - { - typedef typename ProductType::LhsScalar LhsScalar; - typedef typename ProductType::RhsScalar RhsScalar; - typedef typename ProductType::Scalar ResScalar; - typedef typename ProductType::Index Index; - typedef typename ProductType::ActualLhsType ActualLhsType; - typedef typename ProductType::ActualRhsType ActualRhsType; - typedef typename ProductType::_ActualRhsType _ActualRhsType; - typedef typename ProductType::LhsBlasTraits LhsBlasTraits; - typedef typename ProductType::RhsBlasTraits RhsBlasTraits; - - typename add_const::type actualLhs = LhsBlasTraits::extract(prod.lhs()); - typename add_const::type actualRhs = RhsBlasTraits::extract(prod.rhs()); - - ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs()) - * RhsBlasTraits::extractScalarFactor(prod.rhs()); - - enum { - // FIXME find a way to allow an inner stride on the result if packet_traits::size==1 - // on, the other hand it is good for the cache to pack the vector anyways... - DirectlyUseRhs = _ActualRhsType::InnerStrideAtCompileTime==1 - }; - - gemv_static_vector_if static_rhs; - - imp_ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,actualRhs.size(), - DirectlyUseRhs ? const_cast(actualRhs.data()) : static_rhs.data()); - - if(!DirectlyUseRhs) - { - #ifdef IMP_EIGEN_DENSE_STORAGE_CTOR_PLUGIN - int size = actualRhs.size(); - IMP_EIGEN_DENSE_STORAGE_CTOR_PLUGIN - #endif - Map(actualRhsPtr, actualRhs.size()) = actualRhs; - } - - general_matrix_vector_product - ::run( - actualLhs.rows(), actualLhs.cols(), - actualLhs.data(), actualLhs.outerStride(), - actualRhsPtr, 1, - dest.data(), dest.col(0).innerStride(), //NOTE if dest is not a vector at compile-time, then dest.innerStride() might be wrong. (bug 1166) - actualAlpha); - } -}; - -template<> struct gemv_selector -{ - template - static void run(const ProductType& prod, Dest& dest, const typename ProductType::Scalar& alpha) - { - typedef typename Dest::Index Index; - // TODO makes sure dest is sequentially stored in memory, otherwise use a temp - const Index size = prod.rhs().rows(); - for(Index k=0; k struct gemv_selector -{ - template - static void run(const ProductType& prod, Dest& dest, const typename ProductType::Scalar& alpha) - { - typedef typename Dest::Index Index; - // TODO makes sure rhs is sequentially stored in memory, otherwise use a temp - const Index rows = prod.rows(); - for(Index i=0; i -template -inline const typename ProductReturnType::Type -MatrixBase::operator*(const MatrixBase &other) const -{ - // A note regarding the function declaration: In MSVC, this function will sometimes - // not be inlined since DenseStorage is an unwindable object for dynamic - // matrices and product types are holding a member to store the result. - // Thus it does not help tagging this function with IMP_EIGEN_STRONG_INLINE. - enum { - ProductIsValid = Derived::ColsAtCompileTime==Dynamic - || OtherDerived::RowsAtCompileTime==Dynamic - || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime), - AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime, - SameSizes = IMP_EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived) - }; - // note to the lost user: - // * for a dot product use: v1.dot(v2) - // * for a coeff-wise product use: v1.cwiseProduct(v2) - IMP_EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes), - INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS) - IMP_EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors), - INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION) - IMP_EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT) -#ifdef IMP_EIGEN_DEBUG_PRODUCT - internal::product_type::debug(); -#endif - return typename ProductReturnType::Type(derived(), other.derived()); -} - -/** \returns an expression of the matrix product of \c *this and \a other without implicit evaluation. - * - * The returned product will behave like any other expressions: the coefficients of the product will be - * computed once at a time as requested. This might be useful in some extremely rare cases when only - * a small and no coherent fraction of the result's coefficients have to be computed. - * - * \warning This version of the matrix product can be much much slower. So use it only if you know - * what you are doing and that you measured a true speed improvement. - * - * \sa operator*(const MatrixBase&) - */ -template -template -const typename LazyProductReturnType::Type -MatrixBase::lazyProduct(const MatrixBase &other) const -{ - enum { - ProductIsValid = Derived::ColsAtCompileTime==Dynamic - || OtherDerived::RowsAtCompileTime==Dynamic - || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime), - AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime, - SameSizes = IMP_EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived) - }; - // note to the lost user: - // * for a dot product use: v1.dot(v2) - // * for a coeff-wise product use: v1.cwiseProduct(v2) - IMP_EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes), - INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS) - IMP_EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors), - INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION) - IMP_EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT) - - return typename LazyProductReturnType::Type(derived(), other.derived()); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_PRODUCT_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/GenericPacketMath.h b/modules/algebra/include/eigen3/Eigen/src/Core/GenericPacketMath.h deleted file mode 100644 index 1c7ac7ceb8..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/GenericPacketMath.h +++ /dev/null @@ -1,350 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2006-2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_GENERIC_PACKET_MATH_H -#define IMP_EIGEN_GENERIC_PACKET_MATH_H - -namespace IMP_Eigen { - -namespace internal { - -/** \internal - * \file GenericPacketMath.h - * - * Default implementation for types not supported by the vectorization. - * In practice these functions are provided to make easier the writing - * of generic vectorized code. - */ - -#ifndef IMP_EIGEN_DEBUG_ALIGNED_LOAD -#define IMP_EIGEN_DEBUG_ALIGNED_LOAD -#endif - -#ifndef IMP_EIGEN_DEBUG_UNALIGNED_LOAD -#define IMP_EIGEN_DEBUG_UNALIGNED_LOAD -#endif - -#ifndef IMP_EIGEN_DEBUG_ALIGNED_STORE -#define IMP_EIGEN_DEBUG_ALIGNED_STORE -#endif - -#ifndef IMP_EIGEN_DEBUG_UNALIGNED_STORE -#define IMP_EIGEN_DEBUG_UNALIGNED_STORE -#endif - -struct default_packet_traits -{ - enum { - HasAdd = 1, - HasSub = 1, - HasMul = 1, - HasNegate = 1, - HasAbs = 1, - HasAbs2 = 1, - HasMin = 1, - HasMax = 1, - HasConj = 1, - HasSetLinear = 1, - - HasDiv = 0, - HasSqrt = 0, - HasExp = 0, - HasLog = 0, - HasPow = 0, - - HasSin = 0, - HasCos = 0, - HasTan = 0, - HasASin = 0, - HasACos = 0, - HasATan = 0 - }; -}; - -template struct packet_traits : default_packet_traits -{ - typedef T type; - enum { - Vectorizable = 0, - size = 1, - AlignedOnScalar = 0 - }; - enum { - HasAdd = 0, - HasSub = 0, - HasMul = 0, - HasNegate = 0, - HasAbs = 0, - HasAbs2 = 0, - HasMin = 0, - HasMax = 0, - HasConj = 0, - HasSetLinear = 0 - }; -}; - -/** \internal \returns a + b (coeff-wise) */ -template inline Packet -padd(const Packet& a, - const Packet& b) { return a+b; } - -/** \internal \returns a - b (coeff-wise) */ -template inline Packet -psub(const Packet& a, - const Packet& b) { return a-b; } - -/** \internal \returns -a (coeff-wise) */ -template inline Packet -pnegate(const Packet& a) { return -a; } - -/** \internal \returns conj(a) (coeff-wise) */ -template inline Packet -pconj(const Packet& a) { return numext::conj(a); } - -/** \internal \returns a * b (coeff-wise) */ -template inline Packet -pmul(const Packet& a, - const Packet& b) { return a*b; } - -/** \internal \returns a / b (coeff-wise) */ -template inline Packet -pdiv(const Packet& a, - const Packet& b) { return a/b; } - -/** \internal \returns the min of \a a and \a b (coeff-wise) */ -template inline Packet -pmin(const Packet& a, - const Packet& b) { using std::min; return (min)(a, b); } - -/** \internal \returns the max of \a a and \a b (coeff-wise) */ -template inline Packet -pmax(const Packet& a, - const Packet& b) { using std::max; return (max)(a, b); } - -/** \internal \returns the absolute value of \a a */ -template inline Packet -pabs(const Packet& a) { using std::abs; return abs(a); } - -/** \internal \returns the bitwise and of \a a and \a b */ -template inline Packet -pand(const Packet& a, const Packet& b) { return a & b; } - -/** \internal \returns the bitwise or of \a a and \a b */ -template inline Packet -por(const Packet& a, const Packet& b) { return a | b; } - -/** \internal \returns the bitwise xor of \a a and \a b */ -template inline Packet -pxor(const Packet& a, const Packet& b) { return a ^ b; } - -/** \internal \returns the bitwise andnot of \a a and \a b */ -template inline Packet -pandnot(const Packet& a, const Packet& b) { return a & (!b); } - -/** \internal \returns a packet version of \a *from, from must be 16 bytes aligned */ -template inline Packet -pload(const typename unpacket_traits::type* from) { return *from; } - -/** \internal \returns a packet version of \a *from, (un-aligned load) */ -template inline Packet -ploadu(const typename unpacket_traits::type* from) { return *from; } - -/** \internal \returns a packet with elements of \a *from duplicated. - * For instance, for a packet of 8 elements, 4 scalar will be read from \a *from and - * duplicated to form: {from[0],from[0],from[1],from[1],,from[2],from[2],,from[3],from[3]} - * Currently, this function is only used for scalar * complex products. - */ -template inline Packet -ploaddup(const typename unpacket_traits::type* from) { return *from; } - -/** \internal \returns a packet with constant coefficients \a a, e.g.: (a,a,a,a) */ -template inline Packet -pset1(const typename unpacket_traits::type& a) { return a; } - -/** \internal \brief Returns a packet with coefficients (a,a+1,...,a+packet_size-1). */ -template inline typename packet_traits::type -plset(const Scalar& a) { return a; } - -/** \internal copy the packet \a from to \a *to, \a to must be 16 bytes aligned */ -template inline void pstore(Scalar* to, const Packet& from) -{ (*to) = from; } - -/** \internal copy the packet \a from to \a *to, (un-aligned store) */ -template inline void pstoreu(Scalar* to, const Packet& from) -{ (*to) = from; } - -/** \internal tries to do cache prefetching of \a addr */ -template inline void prefetch(const Scalar* addr) -{ -#if !defined(_MSC_VER) -__builtin_prefetch(addr); -#endif -} - -/** \internal \returns the first element of a packet */ -template inline typename unpacket_traits::type pfirst(const Packet& a) -{ return a; } - -/** \internal \returns a packet where the element i contains the sum of the packet of \a vec[i] */ -template inline Packet -preduxp(const Packet* vecs) { return vecs[0]; } - -/** \internal \returns the sum of the elements of \a a*/ -template inline typename unpacket_traits::type predux(const Packet& a) -{ return a; } - -/** \internal \returns the product of the elements of \a a*/ -template inline typename unpacket_traits::type predux_mul(const Packet& a) -{ return a; } - -/** \internal \returns the min of the elements of \a a*/ -template inline typename unpacket_traits::type predux_min(const Packet& a) -{ return a; } - -/** \internal \returns the max of the elements of \a a*/ -template inline typename unpacket_traits::type predux_max(const Packet& a) -{ return a; } - -/** \internal \returns the reversed elements of \a a*/ -template inline Packet preverse(const Packet& a) -{ return a; } - - -/** \internal \returns \a a with real and imaginary part flipped (for complex type only) */ -template inline Packet pcplxflip(const Packet& a) -{ - // FIXME: uncomment the following in case we drop the internal imag and real functions. -// using std::imag; -// using std::real; - return Packet(imag(a),real(a)); -} - -/************************** -* Special math functions -***************************/ - -/** \internal \returns the sine of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet psin(const Packet& a) { using std::sin; return sin(a); } - -/** \internal \returns the cosine of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet pcos(const Packet& a) { using std::cos; return cos(a); } - -/** \internal \returns the tan of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet ptan(const Packet& a) { using std::tan; return tan(a); } - -/** \internal \returns the arc sine of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet pasin(const Packet& a) { using std::asin; return asin(a); } - -/** \internal \returns the arc cosine of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet pacos(const Packet& a) { using std::acos; return acos(a); } - -/** \internal \returns the exp of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet pexp(const Packet& a) { using std::exp; return exp(a); } - -/** \internal \returns the log of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet plog(const Packet& a) { using std::log; return log(a); } - -/** \internal \returns the square-root of \a a (coeff-wise) */ -template IMP_EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS -Packet psqrt(const Packet& a) { using std::sqrt; return sqrt(a); } - -/*************************************************************************** -* The following functions might not have to be overwritten for vectorized types -***************************************************************************/ - -/** \internal copy a packet with constant coeficient \a a (e.g., [a,a,a,a]) to \a *to. \a to must be 16 bytes aligned */ -// NOTE: this function must really be templated on the packet type (think about different packet types for the same scalar type) -template -inline void pstore1(typename unpacket_traits::type* to, const typename unpacket_traits::type& a) -{ - pstore(to, pset1(a)); -} - -/** \internal \returns a * b + c (coeff-wise) */ -template inline Packet -pmadd(const Packet& a, - const Packet& b, - const Packet& c) -{ return padd(pmul(a, b),c); } - -/** \internal \returns a packet version of \a *from. - * If LoadMode equals #Aligned, \a from must be 16 bytes aligned */ -template -inline Packet ploadt(const typename unpacket_traits::type* from) -{ - if(LoadMode == Aligned) - return pload(from); - else - return ploadu(from); -} - -/** \internal copy the packet \a from to \a *to. - * If StoreMode equals #Aligned, \a to must be 16 bytes aligned */ -template -inline void pstoret(Scalar* to, const Packet& from) -{ - if(LoadMode == Aligned) - pstore(to, from); - else - pstoreu(to, from); -} - -/** \internal default implementation of palign() allowing partial specialization */ -template -struct palign_impl -{ - // by default data are aligned, so there is nothing to be done :) - static inline void run(PacketType&, const PacketType&) {} -}; - -/** \internal update \a first using the concatenation of the packet_size minus \a Offset last elements - * of \a first and \a Offset first elements of \a second. - * - * This function is currently only used to optimize matrix-vector products on unligned matrices. - * It takes 2 packets that represent a contiguous memory array, and returns a packet starting - * at the position \a Offset. For instance, for packets of 4 elements, we have: - * Input: - * - first = {f0,f1,f2,f3} - * - second = {s0,s1,s2,s3} - * Output: - * - if Offset==0 then {f0,f1,f2,f3} - * - if Offset==1 then {f1,f2,f3,s0} - * - if Offset==2 then {f2,f3,s0,s1} - * - if Offset==3 then {f3,s0,s1,s3} - */ -template -inline void palign(PacketType& first, const PacketType& second) -{ - palign_impl::run(first,second); -} - -/*************************************************************************** -* Fast complex products (GCC generates a function call which is very slow) -***************************************************************************/ - -template<> inline std::complex pmul(const std::complex& a, const std::complex& b) -{ return std::complex(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); } - -template<> inline std::complex pmul(const std::complex& a, const std::complex& b) -{ return std::complex(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); } - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_GENERIC_PACKET_MATH_H - diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/GlobalFunctions.h b/modules/algebra/include/eigen3/Eigen/src/Core/GlobalFunctions.h deleted file mode 100644 index 68f24029e9..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/GlobalFunctions.h +++ /dev/null @@ -1,92 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2010-2012 Gael Guennebaud -// Copyright (C) 2010 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_GLOBAL_FUNCTIONS_H -#define IMP_EIGEN_GLOBAL_FUNCTIONS_H - -#define IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR) \ - template \ - inline const IMP_Eigen::CwiseUnaryOp, const Derived> \ - NAME(const IMP_Eigen::ArrayBase& x) { \ - return x.derived(); \ - } - -#define IMP_EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \ - \ - template \ - struct NAME##_retval > \ - { \ - typedef const IMP_Eigen::CwiseUnaryOp, const Derived> type; \ - }; \ - template \ - struct NAME##_impl > \ - { \ - static inline typename NAME##_retval >::type run(const IMP_Eigen::ArrayBase& x) \ - { \ - return x.derived(); \ - } \ - }; - - -namespace IMP_Eigen -{ - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(conj,scalar_conjugate_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin,scalar_sin_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sqrt,scalar_sqrt_op) - - template - inline const IMP_Eigen::CwiseUnaryOp, const Derived> - pow(const IMP_Eigen::ArrayBase& x, const typename Derived::Scalar& exponent) { - return x.derived().pow(exponent); - } - - template - inline const IMP_Eigen::CwiseBinaryOp, const Derived, const Derived> - pow(const IMP_Eigen::ArrayBase& x, const IMP_Eigen::ArrayBase& exponents) - { - return IMP_Eigen::CwiseBinaryOp, const Derived, const Derived>( - x.derived(), - exponents.derived() - ); - } - - /** - * \brief Component-wise division of a scalar by array elements. - **/ - template - inline const IMP_Eigen::CwiseUnaryOp, const Derived> - operator/(const typename Derived::Scalar& s, const IMP_Eigen::ArrayBase& a) - { - return IMP_Eigen::CwiseUnaryOp, const Derived>( - a.derived(), - IMP_Eigen::internal::scalar_inverse_mult_op(s) - ); - } - - namespace internal - { - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op) - IMP_EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op) - } -} - -// TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random, internal::isApprox...) - -#endif // IMP_EIGEN_GLOBAL_FUNCTIONS_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/IO.h b/modules/algebra/include/eigen3/Eigen/src/Core/IO.h deleted file mode 100644 index e68995dbbd..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/IO.h +++ /dev/null @@ -1,250 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2008 Benoit Jacob -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_IO_H -#define IMP_EIGEN_IO_H - -namespace IMP_Eigen { - -enum { DontAlignCols = 1 }; -enum { StreamPrecision = -1, - FullPrecision = -2 }; - -namespace internal { -template -std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt); -} - -/** \class IOFormat - * \ingroup Core_Module - * - * \brief Stores a set of parameters controlling the way matrices are printed - * - * List of available parameters: - * - \b precision number of digits for floating point values, or one of the special constants \c StreamPrecision and \c FullPrecision. - * The default is the special value \c StreamPrecision which means to use the - * stream's own precision setting, as set for instance using \c cout.precision(3). The other special value - * \c FullPrecision means that the number of digits will be computed to match the full precision of each floating-point - * type. - * - \b flags an OR-ed combination of flags, the default value is 0, the only currently available flag is \c DontAlignCols which - * allows to disable the alignment of columns, resulting in faster code. - * - \b coeffSeparator string printed between two coefficients of the same row - * - \b rowSeparator string printed between two rows - * - \b rowPrefix string printed at the beginning of each row - * - \b rowSuffix string printed at the end of each row - * - \b matPrefix string printed at the beginning of the matrix - * - \b matSuffix string printed at the end of the matrix - * - * Example: \include IOFormat.cpp - * Output: \verbinclude IOFormat.out - * - * \sa DenseBase::format(), class WithFormat - */ -struct IOFormat -{ - /** Default contructor, see class IOFormat for the meaning of the parameters */ - IOFormat(int _precision = StreamPrecision, int _flags = 0, - const std::string& _coeffSeparator = " ", - const std::string& _rowSeparator = "\n", const std::string& _rowPrefix="", const std::string& _rowSuffix="", - const std::string& _matPrefix="", const std::string& _matSuffix="") - : matPrefix(_matPrefix), matSuffix(_matSuffix), rowPrefix(_rowPrefix), rowSuffix(_rowSuffix), rowSeparator(_rowSeparator), - rowSpacer(""), coeffSeparator(_coeffSeparator), precision(_precision), flags(_flags) - { - int i = int(matSuffix.length())-1; - while (i>=0 && matSuffix[i]!='\n') - { - rowSpacer += ' '; - i--; - } - } - std::string matPrefix, matSuffix; - std::string rowPrefix, rowSuffix, rowSeparator, rowSpacer; - std::string coeffSeparator; - int precision; - int flags; -}; - -/** \class WithFormat - * \ingroup Core_Module - * - * \brief Pseudo expression providing matrix output with given format - * - * \param ExpressionType the type of the object on which IO stream operations are performed - * - * This class represents an expression with stream operators controlled by a given IOFormat. - * It is the return type of DenseBase::format() - * and most of the time this is the only way it is used. - * - * See class IOFormat for some examples. - * - * \sa DenseBase::format(), class IOFormat - */ -template -class WithFormat -{ - public: - - WithFormat(const ExpressionType& matrix, const IOFormat& format) - : m_matrix(matrix), m_format(format) - {} - - friend std::ostream & operator << (std::ostream & s, const WithFormat& wf) - { - return internal::print_matrix(s, wf.m_matrix.eval(), wf.m_format); - } - - protected: - const typename ExpressionType::Nested m_matrix; - IOFormat m_format; -}; - -/** \returns a WithFormat proxy object allowing to print a matrix the with given - * format \a fmt. - * - * See class IOFormat for some examples. - * - * \sa class IOFormat, class WithFormat - */ -template -inline const WithFormat -DenseBase::format(const IOFormat& fmt) const -{ - return WithFormat(derived(), fmt); -} - -namespace internal { - -template -struct significant_decimals_default_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline int run() - { - using std::ceil; - using std::log; - return cast(ceil(-log(NumTraits::epsilon())/log(RealScalar(10)))); - } -}; - -template -struct significant_decimals_default_impl -{ - static inline int run() - { - return 0; - } -}; - -template -struct significant_decimals_impl - : significant_decimals_default_impl::IsInteger> -{}; - -/** \internal - * print the matrix \a _m to the output stream \a s using the output format \a fmt */ -template -std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt) -{ - if(_m.size() == 0) - { - s << fmt.matPrefix << fmt.matSuffix; - return s; - } - - typename Derived::Nested m = _m; - typedef typename Derived::Scalar Scalar; - typedef typename Derived::Index Index; - - Index width = 0; - - std::streamsize explicit_precision; - if(fmt.precision == StreamPrecision) - { - explicit_precision = 0; - } - else if(fmt.precision == FullPrecision) - { - if (NumTraits::IsInteger) - { - explicit_precision = 0; - } - else - { - explicit_precision = significant_decimals_impl::run(); - } - } - else - { - explicit_precision = fmt.precision; - } - - std::streamsize old_precision = 0; - if(explicit_precision) old_precision = s.precision(explicit_precision); - - bool align_cols = !(fmt.flags & DontAlignCols); - if(align_cols) - { - // compute the largest width - for(Index j = 0; j < m.cols(); ++j) - for(Index i = 0; i < m.rows(); ++i) - { - std::stringstream sstr; - sstr.copyfmt(s); - sstr << m.coeff(i,j); - width = std::max(width, Index(sstr.str().length())); - } - } - s << fmt.matPrefix; - for(Index i = 0; i < m.rows(); ++i) - { - if (i) - s << fmt.rowSpacer; - s << fmt.rowPrefix; - if(width) s.width(width); - s << m.coeff(i, 0); - for(Index j = 1; j < m.cols(); ++j) - { - s << fmt.coeffSeparator; - if (width) s.width(width); - s << m.coeff(i, j); - } - s << fmt.rowSuffix; - if( i < m.rows() - 1) - s << fmt.rowSeparator; - } - s << fmt.matSuffix; - if(explicit_precision) s.precision(old_precision); - return s; -} - -} // end namespace internal - -/** \relates DenseBase - * - * Outputs the matrix, to the given stream. - * - * If you wish to print the matrix with a format different than the default, use DenseBase::format(). - * - * It is also possible to change the default format by defining IMP_EIGEN_DEFAULT_IO_FORMAT before including Eigen headers. - * If not defined, this will automatically be defined to IMP_Eigen::IOFormat(), that is the IMP_Eigen::IOFormat with default parameters. - * - * \sa DenseBase::format() - */ -template -std::ostream & operator << -(std::ostream & s, - const DenseBase & m) -{ - return internal::print_matrix(s, m.eval(), IMP_EIGEN_DEFAULT_IO_FORMAT); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_IO_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Map.h b/modules/algebra/include/eigen3/Eigen/src/Core/Map.h deleted file mode 100644 index 08db9634ab..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Map.h +++ /dev/null @@ -1,192 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2007-2010 Benoit Jacob -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_MAP_H -#define IMP_EIGEN_MAP_H - -namespace IMP_Eigen { - -/** \class Map - * \ingroup Core_Module - * - * \brief A matrix or vector expression mapping an existing array of data. - * - * \tparam PlainObjectType the equivalent matrix type of the mapped data - * \tparam MapOptions specifies whether the pointer is \c #Aligned, or \c #Unaligned. - * The default is \c #Unaligned. - * \tparam StrideType optionally specifies strides. By default, Map assumes the memory layout - * of an ordinary, contiguous array. This can be overridden by specifying strides. - * The type passed here must be a specialization of the Stride template, see examples below. - * - * This class represents a matrix or vector expression mapping an existing array of data. - * It can be used to let Eigen interface without any overhead with non-Eigen data structures, - * such as plain C arrays or structures from other libraries. By default, it assumes that the - * data is laid out contiguously in memory. You can however override this by explicitly specifying - * inner and outer strides. - * - * Here's an example of simply mapping a contiguous array as a \ref TopicStorageOrders "column-major" matrix: - * \include Map_simple.cpp - * Output: \verbinclude Map_simple.out - * - * If you need to map non-contiguous arrays, you can do so by specifying strides: - * - * Here's an example of mapping an array as a vector, specifying an inner stride, that is, the pointer - * increment between two consecutive coefficients. Here, we're specifying the inner stride as a compile-time - * fixed value. - * \include Map_inner_stride.cpp - * Output: \verbinclude Map_inner_stride.out - * - * Here's an example of mapping an array while specifying an outer stride. Here, since we're mapping - * as a column-major matrix, 'outer stride' means the pointer increment between two consecutive columns. - * Here, we're specifying the outer stride as a runtime parameter. Note that here \c OuterStride<> is - * a short version of \c OuterStride because the default template parameter of OuterStride - * is \c Dynamic - * \include Map_outer_stride.cpp - * Output: \verbinclude Map_outer_stride.out - * - * For more details and for an example of specifying both an inner and an outer stride, see class Stride. - * - * \b Tip: to change the array of data mapped by a Map object, you can use the C++ - * placement new syntax: - * - * Example: \include Map_placement_new.cpp - * Output: \verbinclude Map_placement_new.out - * - * This class is the return type of PlainObjectBase::Map() but can also be used directly. - * - * \sa PlainObjectBase::Map(), \ref TopicStorageOrders - */ - -namespace internal { -template -struct traits > - : public traits -{ - typedef traits TraitsBase; - typedef typename PlainObjectType::Index Index; - typedef typename PlainObjectType::Scalar Scalar; - enum { - InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0 - ? int(PlainObjectType::InnerStrideAtCompileTime) - : int(StrideType::InnerStrideAtCompileTime), - OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0 - ? int(PlainObjectType::OuterStrideAtCompileTime) - : int(StrideType::OuterStrideAtCompileTime), - HasNoInnerStride = InnerStrideAtCompileTime == 1, - HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0, - HasNoStride = HasNoInnerStride && HasNoOuterStride, - IsAligned = bool(IMP_EIGEN_ALIGN) && ((int(MapOptions)&Aligned)==Aligned), - IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic, - KeepsPacketAccess = bool(HasNoInnerStride) - && ( bool(IsDynamicSize) - || HasNoOuterStride - || ( OuterStrideAtCompileTime!=Dynamic - && ((static_cast(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ), - Flags0 = TraitsBase::Flags & (~NestByRefBit), - Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit), - Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime)) - ? int(Flags1) : int(Flags1 & ~LinearAccessBit), - Flags3 = is_lvalue::value ? int(Flags2) : (int(Flags2) & ~LvalueBit), - Flags = KeepsPacketAccess ? int(Flags3) : (int(Flags3) & ~PacketAccessBit) - }; -private: - enum { Options }; // Expressions don't have Options -}; -} - -template class Map - : public MapBase > -{ - public: - - typedef MapBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Map) - - typedef typename Base::PointerType PointerType; -#if IMP_EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API - typedef const Scalar* PointerArgType; - inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast(ptr); } -#else - typedef PointerType PointerArgType; - inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; } -#endif - - inline Index innerStride() const - { - return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1; - } - - inline Index outerStride() const - { - return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer() - : IsVectorAtCompileTime ? this->size() - : int(Flags)&RowMajorBit ? this->cols() - : this->rows(); - } - - /** Constructor in the fixed-size case. - * - * \param dataPtr pointer to the array to map - * \param a_stride optional Stride object, passing the strides. - */ - inline Map(PointerArgType dataPtr, const StrideType& a_stride = StrideType()) - : Base(cast_to_pointer_type(dataPtr)), m_stride(a_stride) - { - PlainObjectType::Base::_check_template_params(); - } - - /** Constructor in the dynamic-size vector case. - * - * \param dataPtr pointer to the array to map - * \param a_size the size of the vector expression - * \param a_stride optional Stride object, passing the strides. - */ - inline Map(PointerArgType dataPtr, Index a_size, const StrideType& a_stride = StrideType()) - : Base(cast_to_pointer_type(dataPtr), a_size), m_stride(a_stride) - { - PlainObjectType::Base::_check_template_params(); - } - - /** Constructor in the dynamic-size matrix case. - * - * \param dataPtr pointer to the array to map - * \param nbRows the number of rows of the matrix expression - * \param nbCols the number of columns of the matrix expression - * \param a_stride optional Stride object, passing the strides. - */ - inline Map(PointerArgType dataPtr, Index nbRows, Index nbCols, const StrideType& a_stride = StrideType()) - : Base(cast_to_pointer_type(dataPtr), nbRows, nbCols), m_stride(a_stride) - { - PlainObjectType::Base::_check_template_params(); - } - - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) - - protected: - StrideType m_stride; -}; - -template -inline Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> - ::Array(const Scalar *data) -{ - this->_set_noalias(IMP_Eigen::Map(data)); -} - -template -inline Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> - ::Matrix(const Scalar *data) -{ - this->_set_noalias(IMP_Eigen::Map(data)); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_MAP_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/MapBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/MapBase.h deleted file mode 100644 index a685700e69..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/MapBase.h +++ /dev/null @@ -1,251 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2007-2010 Benoit Jacob -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_MAPBASE_H -#define IMP_EIGEN_MAPBASE_H - -#define IMP_EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) \ - IMP_EIGEN_STATIC_ASSERT((int(internal::traits::Flags) & LinearAccessBit) || Derived::IsVectorAtCompileTime, \ - YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT) - -namespace IMP_Eigen { - -/** \class MapBase - * \ingroup Core_Module - * - * \brief Base class for Map and Block expression with direct access - * - * \sa class Map, class Block - */ -template class MapBase - : public internal::dense_xpr_base::type -{ - public: - - typedef typename internal::dense_xpr_base::type Base; - enum { - RowsAtCompileTime = internal::traits::RowsAtCompileTime, - ColsAtCompileTime = internal::traits::ColsAtCompileTime, - SizeAtCompileTime = Base::SizeAtCompileTime - }; - - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::packet_traits::type PacketScalar; - typedef typename NumTraits::Real RealScalar; - typedef typename internal::conditional< - bool(internal::is_lvalue::value), - Scalar *, - const Scalar *>::type - PointerType; - - using Base::derived; -// using Base::RowsAtCompileTime; -// using Base::ColsAtCompileTime; -// using Base::SizeAtCompileTime; - using Base::MaxRowsAtCompileTime; - using Base::MaxColsAtCompileTime; - using Base::MaxSizeAtCompileTime; - using Base::IsVectorAtCompileTime; - using Base::Flags; - using Base::IsRowMajor; - - using Base::rows; - using Base::cols; - using Base::size; - using Base::coeff; - using Base::coeffRef; - using Base::lazyAssign; - using Base::eval; - - using Base::innerStride; - using Base::outerStride; - using Base::rowStride; - using Base::colStride; - - // bug 217 - compile error on ICC 11.1 - using Base::operator=; - - typedef typename Base::CoeffReturnType CoeffReturnType; - - inline Index rows() const { return m_rows.value(); } - inline Index cols() const { return m_cols.value(); } - - /** Returns a pointer to the first coefficient of the matrix or vector. - * - * \note When addressing this data, make sure to honor the strides returned by innerStride() and outerStride(). - * - * \sa innerStride(), outerStride() - */ - inline const Scalar* data() const { return m_data; } - - inline const Scalar& coeff(Index rowId, Index colId) const - { - return m_data[colId * colStride() + rowId * rowStride()]; - } - - inline const Scalar& coeff(Index index) const - { - IMP_EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) - return m_data[index * innerStride()]; - } - - inline const Scalar& coeffRef(Index rowId, Index colId) const - { - return this->m_data[colId * colStride() + rowId * rowStride()]; - } - - inline const Scalar& coeffRef(Index index) const - { - IMP_EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) - return this->m_data[index * innerStride()]; - } - - template - inline PacketScalar packet(Index rowId, Index colId) const - { - return internal::ploadt - (m_data + (colId * colStride() + rowId * rowStride())); - } - - template - inline PacketScalar packet(Index index) const - { - IMP_EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) - return internal::ploadt(m_data + index * innerStride()); - } - - explicit inline MapBase(PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime) - { - IMP_EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) - checkSanity(); - } - - inline MapBase(PointerType dataPtr, Index vecSize) - : m_data(dataPtr), - m_rows(RowsAtCompileTime == Dynamic ? vecSize : Index(RowsAtCompileTime)), - m_cols(ColsAtCompileTime == Dynamic ? vecSize : Index(ColsAtCompileTime)) - { - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - imp_eigen_assert(vecSize >= 0); - imp_eigen_assert(dataPtr == 0 || SizeAtCompileTime == Dynamic || SizeAtCompileTime == vecSize); - checkSanity(); - } - - inline MapBase(PointerType dataPtr, Index nbRows, Index nbCols) - : m_data(dataPtr), m_rows(nbRows), m_cols(nbCols) - { - imp_eigen_assert( (dataPtr == 0) - || ( nbRows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == nbRows) - && nbCols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == nbCols))); - checkSanity(); - } - - #ifdef IMP_EIGEN_MAPBASE_PLUGIN - #include IMP_EIGEN_MAPBASE_PLUGIN - #endif - - protected: - - void checkSanity() const - { - IMP_EIGEN_STATIC_ASSERT(IMP_EIGEN_IMPLIES(internal::traits::Flags&PacketAccessBit, - internal::inner_stride_at_compile_time::ret==1), - PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1); - imp_eigen_assert(IMP_EIGEN_IMPLIES(internal::traits::Flags&AlignedBit, (size_t(m_data) % 16) == 0) - && "input pointer is not aligned on a 16 byte boundary"); - } - - PointerType m_data; - const internal::variable_if_dynamic m_rows; - const internal::variable_if_dynamic m_cols; -}; - -template class MapBase - : public MapBase -{ - typedef MapBase ReadOnlyMapBase; - public: - - typedef MapBase Base; - - typedef typename Base::Scalar Scalar; - typedef typename Base::PacketScalar PacketScalar; - typedef typename Base::Index Index; - typedef typename Base::PointerType PointerType; - - using Base::derived; - using Base::rows; - using Base::cols; - using Base::size; - using Base::coeff; - using Base::coeffRef; - - using Base::innerStride; - using Base::outerStride; - using Base::rowStride; - using Base::colStride; - - typedef typename internal::conditional< - internal::is_lvalue::value, - Scalar, - const Scalar - >::type ScalarWithConstIfNotLvalue; - - inline const Scalar* data() const { return this->m_data; } - inline ScalarWithConstIfNotLvalue* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error - - inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col) - { - return this->m_data[col * colStride() + row * rowStride()]; - } - - inline ScalarWithConstIfNotLvalue& coeffRef(Index index) - { - IMP_EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) - return this->m_data[index * innerStride()]; - } - - template - inline void writePacket(Index row, Index col, const PacketScalar& val) - { - internal::pstoret - (this->m_data + (col * colStride() + row * rowStride()), val); - } - - template - inline void writePacket(Index index, const PacketScalar& val) - { - IMP_EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) - internal::pstoret - (this->m_data + index * innerStride(), val); - } - - explicit inline MapBase(PointerType dataPtr) : Base(dataPtr) {} - inline MapBase(PointerType dataPtr, Index vecSize) : Base(dataPtr, vecSize) {} - inline MapBase(PointerType dataPtr, Index nbRows, Index nbCols) : Base(dataPtr, nbRows, nbCols) {} - - Derived& operator=(const MapBase& other) - { - ReadOnlyMapBase::Base::operator=(other); - return derived(); - } - - // In theory we could simply refer to Base:Base::operator=, but MSVC does not like Base::Base, - // see bugs 821 and 920. - using ReadOnlyMapBase::Base::operator=; -}; - -#undef IMP_EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_MAPBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/MathFunctions.h b/modules/algebra/include/eigen3/Eigen/src/Core/MathFunctions.h deleted file mode 100644 index e8aaf689fa..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/MathFunctions.h +++ /dev/null @@ -1,779 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2010 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_MATHFUNCTIONS_H -#define IMP_EIGEN_MATHFUNCTIONS_H - -namespace IMP_Eigen { - -namespace internal { - -/** \internal \struct global_math_functions_filtering_base - * - * What it does: - * Defines a typedef 'type' as follows: - * - if type T has a member typedef Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl, then - * global_math_functions_filtering_base::type is a typedef for it. - * - otherwise, global_math_functions_filtering_base::type is a typedef for T. - * - * How it's used: - * To allow to defined the global math functions (like sin...) in certain cases, like the Array expressions. - * When you do sin(array1+array2), the object array1+array2 has a complicated expression type, all what you want to know - * is that it inherits ArrayBase. So we implement a partial specialization of sin_impl for ArrayBase. - * So we must make sure to use sin_impl > and not sin_impl, otherwise our partial specialization - * won't be used. How does sin know that? That's exactly what global_math_functions_filtering_base tells it. - * - * How it's implemented: - * SFINAE in the style of enable_if. Highly susceptible of breaking compilers. With GCC, it sure does work, but if you replace - * the typename dummy by an integer template parameter, it doesn't work anymore! - */ - -template -struct global_math_functions_filtering_base -{ - typedef T type; -}; - -template struct always_void { typedef void type; }; - -template -struct global_math_functions_filtering_base - ::type - > -{ - typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type; -}; - -#define IMP_EIGEN_MATHFUNC_IMPL(func, scalar) IMP_Eigen::internal::func##_impl::type> -#define IMP_EIGEN_MATHFUNC_RETVAL(func, scalar) typename IMP_Eigen::internal::func##_retval::type>::type - -/**************************************************************************** -* Implementation of real * -****************************************************************************/ - -template::IsComplex> -struct real_default_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x) - { - return x; - } -}; - -template -struct real_default_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x) - { - using std::real; - return real(x); - } -}; - -template struct real_impl : real_default_impl {}; - -template -struct real_retval -{ - typedef typename NumTraits::Real type; -}; - - -/**************************************************************************** -* Implementation of imag * -****************************************************************************/ - -template::IsComplex> -struct imag_default_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar&) - { - return RealScalar(0); - } -}; - -template -struct imag_default_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x) - { - using std::imag; - return imag(x); - } -}; - -template struct imag_impl : imag_default_impl {}; - -template -struct imag_retval -{ - typedef typename NumTraits::Real type; -}; - -/**************************************************************************** -* Implementation of real_ref * -****************************************************************************/ - -template -struct real_ref_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar& run(Scalar& x) - { - return reinterpret_cast(&x)[0]; - } - static inline const RealScalar& run(const Scalar& x) - { - return reinterpret_cast(&x)[0]; - } -}; - -template -struct real_ref_retval -{ - typedef typename NumTraits::Real & type; -}; - -/**************************************************************************** -* Implementation of imag_ref * -****************************************************************************/ - -template -struct imag_ref_default_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar& run(Scalar& x) - { - return reinterpret_cast(&x)[1]; - } - static inline const RealScalar& run(const Scalar& x) - { - return reinterpret_cast(&x)[1]; - } -}; - -template -struct imag_ref_default_impl -{ - static inline Scalar run(Scalar&) - { - return Scalar(0); - } - static inline const Scalar run(const Scalar&) - { - return Scalar(0); - } -}; - -template -struct imag_ref_impl : imag_ref_default_impl::IsComplex> {}; - -template -struct imag_ref_retval -{ - typedef typename NumTraits::Real & type; -}; - -/**************************************************************************** -* Implementation of conj * -****************************************************************************/ - -template::IsComplex> -struct conj_impl -{ - static inline Scalar run(const Scalar& x) - { - return x; - } -}; - -template -struct conj_impl -{ - static inline Scalar run(const Scalar& x) - { - using std::conj; - return conj(x); - } -}; - -template -struct conj_retval -{ - typedef Scalar type; -}; - -/**************************************************************************** -* Implementation of abs2 * -****************************************************************************/ - -template -struct abs2_impl_default -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x) - { - return x*x; - } -}; - -template -struct abs2_impl_default // IsComplex -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x) - { - return real(x)*real(x) + imag(x)*imag(x); - } -}; - -template -struct abs2_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x) - { - return abs2_impl_default::IsComplex>::run(x); - } -}; - -template -struct abs2_retval -{ - typedef typename NumTraits::Real type; -}; - -/**************************************************************************** -* Implementation of norm1 * -****************************************************************************/ - -template -struct norm1_default_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x) - { - using std::abs; - return abs(real(x)) + abs(imag(x)); - } -}; - -template -struct norm1_default_impl -{ - static inline Scalar run(const Scalar& x) - { - using std::abs; - return abs(x); - } -}; - -template -struct norm1_impl : norm1_default_impl::IsComplex> {}; - -template -struct norm1_retval -{ - typedef typename NumTraits::Real type; -}; - -/**************************************************************************** -* Implementation of hypot * -****************************************************************************/ - -template -struct hypot_impl -{ - typedef typename NumTraits::Real RealScalar; - static inline RealScalar run(const Scalar& x, const Scalar& y) - { - using std::max; - using std::min; - using std::abs; - using std::sqrt; - RealScalar _x = abs(x); - RealScalar _y = abs(y); - RealScalar p = (max)(_x, _y); - if(p==RealScalar(0)) return RealScalar(0); - RealScalar q = (min)(_x, _y); - RealScalar qp = q/p; - return p * sqrt(RealScalar(1) + qp*qp); - } -}; - -template -struct hypot_retval -{ - typedef typename NumTraits::Real type; -}; - -/**************************************************************************** -* Implementation of cast * -****************************************************************************/ - -template -struct cast_impl -{ - static inline NewType run(const OldType& x) - { - return static_cast(x); - } -}; - -// here, for once, we're plainly returning NewType: we don't want cast to do weird things. - -template -inline NewType cast(const OldType& x) -{ - return cast_impl::run(x); -} - -/**************************************************************************** -* Implementation of atanh2 * -****************************************************************************/ - -template -struct atanh2_default_impl -{ - typedef Scalar retval; - typedef typename NumTraits::Real RealScalar; - static inline Scalar run(const Scalar& x, const Scalar& y) - { - using std::abs; - using std::log; - using std::sqrt; - Scalar z = x / y; - if (y == Scalar(0) || abs(z) > sqrt(NumTraits::epsilon())) - return RealScalar(0.5) * log((y + x) / (y - x)); - else - return z + z*z*z / RealScalar(3); - } -}; - -template -struct atanh2_default_impl -{ - static inline Scalar run(const Scalar&, const Scalar&) - { - IMP_EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar) - return Scalar(0); - } -}; - -template -struct atanh2_impl : atanh2_default_impl::IsInteger> {}; - -template -struct atanh2_retval -{ - typedef Scalar type; -}; - -/**************************************************************************** -* Implementation of pow * -****************************************************************************/ - -template -struct pow_default_impl -{ - typedef Scalar retval; - static inline Scalar run(const Scalar& x, const Scalar& y) - { - using std::pow; - return pow(x, y); - } -}; - -template -struct pow_default_impl -{ - static inline Scalar run(Scalar x, Scalar y) - { - Scalar res(1); - imp_eigen_assert(!NumTraits::IsSigned || y >= 0); - if(y & 1) res *= x; - y >>= 1; - while(y) - { - x *= x; - if(y&1) res *= x; - y >>= 1; - } - return res; - } -}; - -template -struct pow_impl : pow_default_impl::IsInteger> {}; - -template -struct pow_retval -{ - typedef Scalar type; -}; - -/**************************************************************************** -* Implementation of random * -****************************************************************************/ - -template -struct random_default_impl {}; - -template -struct random_impl : random_default_impl::IsComplex, NumTraits::IsInteger> {}; - -template -struct random_retval -{ - typedef Scalar type; -}; - -template inline IMP_EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y); -template inline IMP_EIGEN_MATHFUNC_RETVAL(random, Scalar) random(); - -template -struct random_default_impl -{ - static inline Scalar run(const Scalar& x, const Scalar& y) - { - return x + (y-x) * Scalar(std::rand()) / Scalar(RAND_MAX); - } - static inline Scalar run() - { - return run(Scalar(NumTraits::IsSigned ? -1 : 0), Scalar(1)); - } -}; - -enum { - floor_log2_terminate, - floor_log2_move_up, - floor_log2_move_down, - floor_log2_bogus -}; - -template struct floor_log2_selector -{ - enum { middle = (lower + upper) / 2, - value = (upper <= lower + 1) ? int(floor_log2_terminate) - : (n < (1 << middle)) ? int(floor_log2_move_down) - : (n==0) ? int(floor_log2_bogus) - : int(floor_log2_move_up) - }; -}; - -template::value> -struct floor_log2 {}; - -template -struct floor_log2 -{ - enum { value = floor_log2::middle>::value }; -}; - -template -struct floor_log2 -{ - enum { value = floor_log2::middle, upper>::value }; -}; - -template -struct floor_log2 -{ - enum { value = (n >= ((unsigned int)(1) << (lower+1))) ? lower+1 : lower }; -}; - -template -struct floor_log2 -{ - // no value, error at compile time -}; - -template -struct random_default_impl -{ - typedef typename NumTraits::NonInteger NonInteger; - - static inline Scalar run(const Scalar& x, const Scalar& y) - { - return x + Scalar((NonInteger(y)-x+1) * std::rand() / (RAND_MAX + NonInteger(1))); - } - - static inline Scalar run() - { -#ifdef IMP_EIGEN_MAKING_DOCS - return run(Scalar(NumTraits::IsSigned ? -10 : 0), Scalar(10)); -#else - enum { rand_bits = floor_log2<(unsigned int)(RAND_MAX)+1>::value, - scalar_bits = sizeof(Scalar) * CHAR_BIT, - shift = IMP_EIGEN_PLAIN_ENUM_MAX(0, int(rand_bits) - int(scalar_bits)), - offset = NumTraits::IsSigned ? (1 << (IMP_EIGEN_PLAIN_ENUM_MIN(rand_bits,scalar_bits)-1)) : 0 - }; - return Scalar((std::rand() >> shift) - offset); -#endif - } -}; - -template -struct random_default_impl -{ - static inline Scalar run(const Scalar& x, const Scalar& y) - { - return Scalar(random(real(x), real(y)), - random(imag(x), imag(y))); - } - static inline Scalar run() - { - typedef typename NumTraits::Real RealScalar; - return Scalar(random(), random()); - } -}; - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y) -{ - return IMP_EIGEN_MATHFUNC_IMPL(random, Scalar)::run(x, y); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(random, Scalar) random() -{ - return IMP_EIGEN_MATHFUNC_IMPL(random, Scalar)::run(); -} - -} // end namespace internal - -/**************************************************************************** -* Generic math function * -****************************************************************************/ - -namespace numext { - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x) -{ - return IMP_EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x); -} - -template -inline typename internal::add_const_on_value_type< IMP_EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar& x) -{ - return internal::real_ref_impl::run(x); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x) -{ - return IMP_EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x) -{ - return IMP_EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x); -} - -template -inline typename internal::add_const_on_value_type< IMP_EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type imag_ref(const Scalar& x) -{ - return internal::imag_ref_impl::run(x); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x) -{ - return IMP_EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x) -{ - return IMP_EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x) -{ - return IMP_EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x) -{ - return IMP_EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y) -{ - return IMP_EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(atanh2, Scalar) atanh2(const Scalar& x, const Scalar& y) -{ - return IMP_EIGEN_MATHFUNC_IMPL(atanh2, Scalar)::run(x, y); -} - -template -inline IMP_EIGEN_MATHFUNC_RETVAL(pow, Scalar) pow(const Scalar& x, const Scalar& y) -{ - return IMP_EIGEN_MATHFUNC_IMPL(pow, Scalar)::run(x, y); -} - -// std::isfinite is non standard, so let's define our own version, -// even though it is not very efficient. -template bool (isfinite)(const T& x) -{ - return x::highest() && x>NumTraits::lowest(); -} - -} // end namespace numext - -namespace internal { - -/**************************************************************************** -* Implementation of fuzzy comparisons * -****************************************************************************/ - -template -struct scalar_fuzzy_default_impl {}; - -template -struct scalar_fuzzy_default_impl -{ - typedef typename NumTraits::Real RealScalar; - template - static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec) - { - using std::abs; - return abs(x) <= abs(y) * prec; - } - static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) - { - using std::min; - using std::abs; - return abs(x - y) <= (min)(abs(x), abs(y)) * prec; - } - static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec) - { - return x <= y || isApprox(x, y, prec); - } -}; - -template -struct scalar_fuzzy_default_impl -{ - typedef typename NumTraits::Real RealScalar; - template - static inline bool isMuchSmallerThan(const Scalar& x, const Scalar&, const RealScalar&) - { - return x == Scalar(0); - } - static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar&) - { - return x == y; - } - static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar&) - { - return x <= y; - } -}; - -template -struct scalar_fuzzy_default_impl -{ - typedef typename NumTraits::Real RealScalar; - template - static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec) - { - return numext::abs2(x) <= numext::abs2(y) * prec * prec; - } - static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) - { - using std::min; - return numext::abs2(x - y) <= (min)(numext::abs2(x), numext::abs2(y)) * prec * prec; - } -}; - -template -struct scalar_fuzzy_impl : scalar_fuzzy_default_impl::IsComplex, NumTraits::IsInteger> {}; - -template -inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, - const typename NumTraits::Real &precision = NumTraits::dummy_precision()) -{ - return scalar_fuzzy_impl::template isMuchSmallerThan(x, y, precision); -} - -template -inline bool isApprox(const Scalar& x, const Scalar& y, - const typename NumTraits::Real &precision = NumTraits::dummy_precision()) -{ - return scalar_fuzzy_impl::isApprox(x, y, precision); -} - -template -inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, - const typename NumTraits::Real &precision = NumTraits::dummy_precision()) -{ - return scalar_fuzzy_impl::isApproxOrLessThan(x, y, precision); -} - -/****************************************** -*** The special case of the bool type *** -******************************************/ - -template<> struct random_impl -{ - static inline bool run() - { - return random(0,1)==0 ? false : true; - } -}; - -template<> struct scalar_fuzzy_impl -{ - typedef bool RealScalar; - - template - static inline bool isMuchSmallerThan(const bool& x, const bool&, const bool&) - { - return !x; - } - - static inline bool isApprox(bool x, bool y, bool) - { - return x == y; - } - - static inline bool isApproxOrLessThan(const bool& x, const bool& y, const bool&) - { - return (!x) || y; - } - -}; - - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_MATHFUNCTIONS_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Matrix.h b/modules/algebra/include/eigen3/Eigen/src/Core/Matrix.h deleted file mode 100644 index bd5bc4fc6d..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Matrix.h +++ /dev/null @@ -1,420 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2010 Benoit Jacob -// Copyright (C) 2008-2009 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_MATRIX_H -#define IMP_EIGEN_MATRIX_H - -namespace IMP_Eigen { - -/** \class Matrix - * \ingroup Core_Module - * - * \brief The matrix class, also used for vectors and row-vectors - * - * The %Matrix class is the work-horse for all \em dense (\ref dense "note") matrices and vectors within Eigen. - * Vectors are matrices with one column, and row-vectors are matrices with one row. - * - * The %Matrix class encompasses \em both fixed-size and dynamic-size objects (\ref fixedsize "note"). - * - * The first three template parameters are required: - * \tparam _Scalar \anchor matrix_tparam_scalar Numeric type, e.g. float, double, int or std::complex. - * User defined sclar types are supported as well (see \ref user_defined_scalars "here"). - * \tparam _Rows Number of rows, or \b Dynamic - * \tparam _Cols Number of columns, or \b Dynamic - * - * The remaining template parameters are optional -- in most cases you don't have to worry about them. - * \tparam _Options \anchor matrix_tparam_options A combination of either \b #RowMajor or \b #ColMajor, and of either - * \b #AutoAlign or \b #DontAlign. - * The former controls \ref TopicStorageOrders "storage order", and defaults to column-major. The latter controls alignment, which is required - * for vectorization. It defaults to aligning matrices except for fixed sizes that aren't a multiple of the packet size. - * \tparam _MaxRows Maximum number of rows. Defaults to \a _Rows (\ref maxrows "note"). - * \tparam _MaxCols Maximum number of columns. Defaults to \a _Cols (\ref maxrows "note"). - * - * Eigen provides a number of typedefs covering the usual cases. Here are some examples: - * - * \li \c Matrix2d is a 2x2 square matrix of doubles (\c Matrix) - * \li \c Vector4f is a vector of 4 floats (\c Matrix) - * \li \c RowVector3i is a row-vector of 3 ints (\c Matrix) - * - * \li \c MatrixXf is a dynamic-size matrix of floats (\c Matrix) - * \li \c VectorXf is a dynamic-size vector of floats (\c Matrix) - * - * \li \c Matrix2Xf is a partially fixed-size (dynamic-size) matrix of floats (\c Matrix) - * \li \c MatrixX3d is a partially dynamic-size (fixed-size) matrix of double (\c Matrix) - * - * See \link matrixtypedefs this page \endlink for a complete list of predefined \em %Matrix and \em Vector typedefs. - * - * You can access elements of vectors and matrices using normal subscripting: - * - * \code - * IMP_Eigen::VectorXd v(10); - * v[0] = 0.1; - * v[1] = 0.2; - * v(0) = 0.3; - * v(1) = 0.4; - * - * IMP_Eigen::MatrixXi m(10, 10); - * m(0, 1) = 1; - * m(0, 2) = 2; - * m(0, 3) = 3; - * \endcode - * - * This class can be extended with the help of the plugin mechanism described on the page - * \ref TopicCustomizingEigen by defining the preprocessor symbol \c IMP_EIGEN_MATRIX_PLUGIN. - * - * Some notes: - * - *
- *
\anchor dense Dense versus sparse:
- *
This %Matrix class handles dense, not sparse matrices and vectors. For sparse matrices and vectors, see the Sparse module. - * - * Dense matrices and vectors are plain usual arrays of coefficients. All the coefficients are stored, in an ordinary contiguous array. - * This is unlike Sparse matrices and vectors where the coefficients are stored as a list of nonzero coefficients.
- * - *
\anchor fixedsize Fixed-size versus dynamic-size:
- *
Fixed-size means that the numbers of rows and columns are known are compile-time. In this case, Eigen allocates the array - * of coefficients as a fixed-size array, as a class member. This makes sense for very small matrices, typically up to 4x4, sometimes up - * to 16x16. Larger matrices should be declared as dynamic-size even if one happens to know their size at compile-time. - * - * Dynamic-size means that the numbers of rows or columns are not necessarily known at compile-time. In this case they are runtime - * variables, and the array of coefficients is allocated dynamically on the heap. - * - * Note that \em dense matrices, be they Fixed-size or Dynamic-size, do not expand dynamically in the sense of a std::map. - * If you want this behavior, see the Sparse module.
- * - *
\anchor maxrows _MaxRows and _MaxCols:
- *
In most cases, one just leaves these parameters to the default values. - * These parameters mean the maximum size of rows and columns that the matrix may have. They are useful in cases - * when the exact numbers of rows and columns are not known are compile-time, but it is known at compile-time that they cannot - * exceed a certain value. This happens when taking dynamic-size blocks inside fixed-size matrices: in this case _MaxRows and _MaxCols - * are the dimensions of the original matrix, while _Rows and _Cols are Dynamic.
- *
- * - * \see MatrixBase for the majority of the API methods for matrices, \ref TopicClassHierarchy, - * \ref TopicStorageOrders - */ - -namespace internal { -template -struct traits > -{ - typedef _Scalar Scalar; - typedef Dense StorageKind; - typedef DenseIndex Index; - typedef MatrixXpr XprKind; - enum { - RowsAtCompileTime = _Rows, - ColsAtCompileTime = _Cols, - MaxRowsAtCompileTime = _MaxRows, - MaxColsAtCompileTime = _MaxCols, - Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret, - CoeffReadCost = NumTraits::ReadCost, - Options = _Options, - InnerStrideAtCompileTime = 1, - OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime - }; -}; -} - -template -class Matrix - : public PlainObjectBase > -{ - public: - - /** \brief Base class typedef. - * \sa PlainObjectBase - */ - typedef PlainObjectBase Base; - - enum { Options = _Options }; - - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Matrix) - - typedef typename Base::PlainObject PlainObject; - - using Base::base; - using Base::coeffRef; - - /** - * \brief Assigns matrices to each other. - * - * \note This is a special case of the templated operator=. Its purpose is - * to prevent a default operator= from hiding the templated operator=. - * - * \callgraph - */ - IMP_EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other) - { - return Base::_set(other); - } - - /** \internal - * \brief Copies the value of the expression \a other into \c *this with automatic resizing. - * - * *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized), - * it will be initialized. - * - * Note that copying a row-vector into a vector (and conversely) is allowed. - * The resizing, if any, is then done in the appropriate way so that row-vectors - * remain row-vectors and vectors remain vectors. - */ - template - IMP_EIGEN_STRONG_INLINE Matrix& operator=(const MatrixBase& other) - { - return Base::_set(other); - } - - /* Here, doxygen failed to copy the brief information when using \copydoc */ - - /** - * \brief Copies the generic expression \a other into *this. - * \copydetails DenseBase::operator=(const EigenBase &other) - */ - template - IMP_EIGEN_STRONG_INLINE Matrix& operator=(const EigenBase &other) - { - return Base::operator=(other); - } - - template - IMP_EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue& func) - { - return Base::operator=(func); - } - - /** \brief Default constructor. - * - * For fixed-size matrices, does nothing. - * - * For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix - * is called a null matrix. This constructor is the unique way to create null matrices: resizing - * a matrix to 0 is not supported. - * - * \sa resize(Index,Index) - */ - IMP_EIGEN_STRONG_INLINE Matrix() : Base() - { - Base::_check_template_params(); - IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } - - // FIXME is it still needed - Matrix(internal::constructor_without_unaligned_array_assert) - : Base(internal::constructor_without_unaligned_array_assert()) - { Base::_check_template_params(); IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED } - -#ifdef IMP_EIGEN_HAVE_RVALUE_REFERENCES - Matrix(Matrix&& other) - : Base(std::move(other)) - { - Base::_check_template_params(); - if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic) - Base::_set_noalias(other); - } - Matrix& operator=(Matrix&& other) - { - other.swap(*this); - return *this; - } -#endif - - /** \brief Constructs a vector or row-vector with given dimension. \only_for_vectors - * - * Note that this is only useful for dynamic-size vectors. For fixed-size vectors, - * it is redundant to pass the dimension here, so it makes more sense to use the default - * constructor Matrix() instead. - */ - IMP_EIGEN_STRONG_INLINE explicit Matrix(Index dim) - : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim) - { - Base::_check_template_params(); - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix) - imp_eigen_assert(dim >= 0); - imp_eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); - IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - template - IMP_EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y) - { - Base::_check_template_params(); - Base::template _init2(x, y); - } - #else - /** \brief Constructs an uninitialized matrix with \a rows rows and \a cols columns. - * - * This is useful for dynamic-size matrices. For fixed-size matrices, - * it is redundant to pass these parameters, so one should use the default constructor - * Matrix() instead. */ - Matrix(Index rows, Index cols); - /** \brief Constructs an initialized 2D vector with given coefficients */ - Matrix(const Scalar& x, const Scalar& y); - #endif - - /** \brief Constructs an initialized 3D vector with given coefficients */ - IMP_EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z) - { - Base::_check_template_params(); - IMP_EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3) - m_storage.data()[0] = x; - m_storage.data()[1] = y; - m_storage.data()[2] = z; - } - /** \brief Constructs an initialized 4D vector with given coefficients */ - IMP_EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w) - { - Base::_check_template_params(); - IMP_EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 4) - m_storage.data()[0] = x; - m_storage.data()[1] = y; - m_storage.data()[2] = z; - m_storage.data()[3] = w; - } - - explicit Matrix(const Scalar *data); - - /** \brief Constructor copying the value of the expression \a other */ - template - IMP_EIGEN_STRONG_INLINE Matrix(const MatrixBase& other) - : Base(other.rows() * other.cols(), other.rows(), other.cols()) - { - // This test resides here, to bring the error messages closer to the user. Normally, these checks - // are performed deeply within the library, thus causing long and scary error traces. - IMP_EIGEN_STATIC_ASSERT((internal::is_same::value), - YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - - Base::_check_template_params(); - Base::_set_noalias(other); - } - /** \brief Copy constructor */ - IMP_EIGEN_STRONG_INLINE Matrix(const Matrix& other) - : Base(other.rows() * other.cols(), other.rows(), other.cols()) - { - Base::_check_template_params(); - Base::_set_noalias(other); - } - /** \brief Copy constructor with in-place evaluation */ - template - IMP_EIGEN_STRONG_INLINE Matrix(const ReturnByValue& other) - { - Base::_check_template_params(); - Base::resize(other.rows(), other.cols()); - other.evalTo(*this); - } - - /** \brief Copy constructor for generic expressions. - * \sa MatrixBase::operator=(const EigenBase&) - */ - template - IMP_EIGEN_STRONG_INLINE Matrix(const EigenBase &other) - : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols()) - { - Base::_check_template_params(); - Base::_resize_to_match(other); - // FIXME/CHECK: isn't *this = other.derived() more efficient. it allows to - // go for pure _set() implementations, right? - *this = other; - } - - /** \internal - * \brief Override MatrixBase::swap() since for dynamic-sized matrices - * of same type it is enough to swap the data pointers. - */ - template - void swap(MatrixBase const & other) - { this->_swap(other.derived()); } - - inline Index innerStride() const { return 1; } - inline Index outerStride() const { return this->innerSize(); } - - /////////// Geometry module /////////// - - template - explicit Matrix(const RotationBase& r); - template - Matrix& operator=(const RotationBase& r); - - #ifdef IMP_EIGEN2_SUPPORT - template - explicit Matrix(const eigen2_RotationBase& r); - template - Matrix& operator=(const eigen2_RotationBase& r); - #endif - - // allow to extend Matrix outside Eigen - #ifdef IMP_EIGEN_MATRIX_PLUGIN - #include IMP_EIGEN_MATRIX_PLUGIN - #endif - - protected: - template - friend struct internal::conservative_resize_like_impl; - - using Base::m_storage; -}; - -/** \defgroup matrixtypedefs Global matrix typedefs - * - * \ingroup Core_Module - * - * Eigen defines several typedef shortcuts for most common matrix and vector types. - * - * The general patterns are the following: - * - * \c MatrixSizeType where \c Size can be \c 2,\c 3,\c 4 for fixed size square matrices or \c X for dynamic size, - * and where \c Type can be \c i for integer, \c f for float, \c d for double, \c cf for complex float, \c cd - * for complex double. - * - * For example, \c Matrix3d is a fixed-size 3x3 matrix type of doubles, and \c MatrixXf is a dynamic-size matrix of floats. - * - * There are also \c VectorSizeType and \c RowVectorSizeType which are self-explanatory. For example, \c Vector4cf is - * a fixed-size vector of 4 complex floats. - * - * \sa class Matrix - */ - -#define IMP_EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ -/** \ingroup matrixtypedefs */ \ -typedef Matrix Matrix##SizeSuffix##TypeSuffix; \ -/** \ingroup matrixtypedefs */ \ -typedef Matrix Vector##SizeSuffix##TypeSuffix; \ -/** \ingroup matrixtypedefs */ \ -typedef Matrix RowVector##SizeSuffix##TypeSuffix; - -#define IMP_EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \ -/** \ingroup matrixtypedefs */ \ -typedef Matrix Matrix##Size##X##TypeSuffix; \ -/** \ingroup matrixtypedefs */ \ -typedef Matrix Matrix##X##Size##TypeSuffix; - -#define IMP_EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ -IMP_EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ -IMP_EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ -IMP_EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ -IMP_EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \ -IMP_EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \ -IMP_EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \ -IMP_EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4) - -IMP_EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i) -IMP_EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f) -IMP_EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d) -IMP_EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex, cf) -IMP_EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex, cd) - -#undef IMP_EIGEN_MAKE_TYPEDEFS_ALL_SIZES -#undef IMP_EIGEN_MAKE_TYPEDEFS -#undef IMP_EIGEN_MAKE_FIXED_TYPEDEFS - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_MATRIX_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/MatrixBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/MatrixBase.h deleted file mode 100644 index aa5e7203e1..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/MatrixBase.h +++ /dev/null @@ -1,563 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2009 Benoit Jacob -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_MATRIXBASE_H -#define IMP_EIGEN_MATRIXBASE_H - -namespace IMP_Eigen { - -/** \class MatrixBase - * \ingroup Core_Module - * - * \brief Base class for all dense matrices, vectors, and expressions - * - * This class is the base that is inherited by all matrix, vector, and related expression - * types. Most of the Eigen API is contained in this class, and its base classes. Other important - * classes for the Eigen API are Matrix, and VectorwiseOp. - * - * Note that some methods are defined in other modules such as the \ref LU_Module LU module - * for all functions related to matrix inversions. - * - * \tparam Derived is the derived type, e.g. a matrix type, or an expression, etc. - * - * When writing a function taking Eigen objects as argument, if you want your function - * to take as argument any matrix, vector, or expression, just let it take a - * MatrixBase argument. As an example, here is a function printFirstRow which, given - * a matrix, vector, or expression \a x, prints the first row of \a x. - * - * \code - template - void printFirstRow(const IMP_Eigen::MatrixBase& x) - { - cout << x.row(0) << endl; - } - * \endcode - * - * This class can be extended with the help of the plugin mechanism described on the page - * \ref TopicCustomizingEigen by defining the preprocessor symbol \c IMP_EIGEN_MATRIXBASE_PLUGIN. - * - * \sa \ref TopicClassHierarchy - */ -template class MatrixBase - : public DenseBase -{ - public: -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef MatrixBase StorageBaseType; - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::packet_traits::type PacketScalar; - typedef typename NumTraits::Real RealScalar; - - typedef DenseBase Base; - using Base::RowsAtCompileTime; - using Base::ColsAtCompileTime; - using Base::SizeAtCompileTime; - using Base::MaxRowsAtCompileTime; - using Base::MaxColsAtCompileTime; - using Base::MaxSizeAtCompileTime; - using Base::IsVectorAtCompileTime; - using Base::Flags; - using Base::CoeffReadCost; - - using Base::derived; - using Base::const_cast_derived; - using Base::rows; - using Base::cols; - using Base::size; - using Base::coeff; - using Base::coeffRef; - using Base::lazyAssign; - using Base::eval; - using Base::operator+=; - using Base::operator-=; - using Base::operator*=; - using Base::operator/=; - - typedef typename Base::CoeffReturnType CoeffReturnType; - typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType; - typedef typename Base::RowXpr RowXpr; - typedef typename Base::ColXpr ColXpr; -#endif // not IMP_EIGEN_PARSED_BY_DOXYGEN - - - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** type of the equivalent square matrix */ - typedef Matrix SquareMatrixType; -#endif // not IMP_EIGEN_PARSED_BY_DOXYGEN - - /** \returns the size of the main diagonal, which is min(rows(),cols()). - * \sa rows(), cols(), SizeAtCompileTime. */ - inline Index diagonalSize() const { return (std::min)(rows(),cols()); } - - /** \brief The plain matrix type corresponding to this expression. - * - * This is not necessarily exactly the return type of eval(). In the case of plain matrices, - * the return type of eval() is a const reference to a matrix, not a matrix! It is however guaranteed - * that the return type of eval() is either PlainObject or const PlainObject&. - */ - typedef Matrix::Scalar, - internal::traits::RowsAtCompileTime, - internal::traits::ColsAtCompileTime, - AutoAlign | (internal::traits::Flags&RowMajorBit ? RowMajor : ColMajor), - internal::traits::MaxRowsAtCompileTime, - internal::traits::MaxColsAtCompileTime - > PlainObject; - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** \internal Represents a matrix with all coefficients equal to one another*/ - typedef CwiseNullaryOp,Derived> ConstantReturnType; - /** \internal the return type of MatrixBase::adjoint() */ - typedef typename internal::conditional::IsComplex, - CwiseUnaryOp, ConstTransposeReturnType>, - ConstTransposeReturnType - >::type AdjointReturnType; - /** \internal Return type of eigenvalues() */ - typedef Matrix, internal::traits::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType; - /** \internal the return type of identity */ - typedef CwiseNullaryOp,Derived> IdentityReturnType; - /** \internal the return type of unit vectors */ - typedef Block, SquareMatrixType>, - internal::traits::RowsAtCompileTime, - internal::traits::ColsAtCompileTime> BasisReturnType; -#endif // not IMP_EIGEN_PARSED_BY_DOXYGEN - -#define IMP_EIGEN_CURRENT_STORAGE_BASE_CLASS IMP_Eigen::MatrixBase -# include "../plugins/CommonCwiseUnaryOps.h" -# include "../plugins/CommonCwiseBinaryOps.h" -# include "../plugins/MatrixCwiseUnaryOps.h" -# include "../plugins/MatrixCwiseBinaryOps.h" -# ifdef IMP_EIGEN_MATRIXBASE_PLUGIN -# include IMP_EIGEN_MATRIXBASE_PLUGIN -# endif -#undef IMP_EIGEN_CURRENT_STORAGE_BASE_CLASS - - /** Special case of the template operator=, in order to prevent the compiler - * from generating a default operator= (issue hit with g++ 4.1) - */ - Derived& operator=(const MatrixBase& other); - - // We cannot inherit here via Base::operator= since it is causing - // trouble with MSVC. - - template - Derived& operator=(const DenseBase& other); - - template - Derived& operator=(const EigenBase& other); - - template - Derived& operator=(const ReturnByValue& other); - - template - Derived& lazyAssign(const ProductBase& other); - - template - Derived& lazyAssign(const MatrixPowerProduct& other); - - template - Derived& operator+=(const MatrixBase& other); - template - Derived& operator-=(const MatrixBase& other); - - template - const typename ProductReturnType::Type - operator*(const MatrixBase &other) const; - - template - const typename LazyProductReturnType::Type - lazyProduct(const MatrixBase &other) const; - - template - Derived& operator*=(const EigenBase& other); - - template - void applyOnTheLeft(const EigenBase& other); - - template - void applyOnTheRight(const EigenBase& other); - - template - const DiagonalProduct - operator*(const DiagonalBase &diagonal) const; - - template - typename internal::scalar_product_traits::Scalar,typename internal::traits::Scalar>::ReturnType - dot(const MatrixBase& other) const; - - #ifdef IMP_EIGEN2_SUPPORT - template - Scalar eigen2_dot(const MatrixBase& other) const; - #endif - - RealScalar squaredNorm() const; - RealScalar norm() const; - RealScalar stableNorm() const; - RealScalar blueNorm() const; - RealScalar hypotNorm() const; - const PlainObject normalized() const; - void normalize(); - - const AdjointReturnType adjoint() const; - void adjointInPlace(); - - typedef Diagonal DiagonalReturnType; - DiagonalReturnType diagonal(); - typedef typename internal::add_const >::type ConstDiagonalReturnType; - ConstDiagonalReturnType diagonal() const; - - template struct DiagonalIndexReturnType { typedef Diagonal Type; }; - template struct ConstDiagonalIndexReturnType { typedef const Diagonal Type; }; - - template typename DiagonalIndexReturnType::Type diagonal(); - template typename ConstDiagonalIndexReturnType::Type diagonal() const; - - typedef Diagonal DiagonalDynamicIndexReturnType; - typedef typename internal::add_const >::type ConstDiagonalDynamicIndexReturnType; - - DiagonalDynamicIndexReturnType diagonal(Index index); - ConstDiagonalDynamicIndexReturnType diagonal(Index index) const; - - #ifdef IMP_EIGEN2_SUPPORT - template typename internal::eigen2_part_return_type::type part(); - template const typename internal::eigen2_part_return_type::type part() const; - - // huuuge hack. make Eigen2's matrix.part() work in eigen3. Problem: Diagonal is now a class template instead - // of an integer constant. Solution: overload the part() method template wrt template parameters list. - template class U> - const DiagonalWrapper part() const - { return diagonal().asDiagonal(); } - #endif // IMP_EIGEN2_SUPPORT - - template struct TriangularViewReturnType { typedef TriangularView Type; }; - template struct ConstTriangularViewReturnType { typedef const TriangularView Type; }; - - template typename TriangularViewReturnType::Type triangularView(); - template typename ConstTriangularViewReturnType::Type triangularView() const; - - template struct SelfAdjointViewReturnType { typedef SelfAdjointView Type; }; - template struct ConstSelfAdjointViewReturnType { typedef const SelfAdjointView Type; }; - - template typename SelfAdjointViewReturnType::Type selfadjointView(); - template typename ConstSelfAdjointViewReturnType::Type selfadjointView() const; - - const SparseView sparseView(const Scalar& m_reference = Scalar(0), - const typename NumTraits::Real& m_epsilon = NumTraits::dummy_precision()) const; - static const IdentityReturnType Identity(); - static const IdentityReturnType Identity(Index rows, Index cols); - static const BasisReturnType Unit(Index size, Index i); - static const BasisReturnType Unit(Index i); - static const BasisReturnType UnitX(); - static const BasisReturnType UnitY(); - static const BasisReturnType UnitZ(); - static const BasisReturnType UnitW(); - - const DiagonalWrapper asDiagonal() const; - const PermutationWrapper asPermutation() const; - - Derived& setIdentity(); - Derived& setIdentity(Index rows, Index cols); - - bool isIdentity(const RealScalar& prec = NumTraits::dummy_precision()) const; - bool isDiagonal(const RealScalar& prec = NumTraits::dummy_precision()) const; - - bool isUpperTriangular(const RealScalar& prec = NumTraits::dummy_precision()) const; - bool isLowerTriangular(const RealScalar& prec = NumTraits::dummy_precision()) const; - - template - bool isOrthogonal(const MatrixBase& other, - const RealScalar& prec = NumTraits::dummy_precision()) const; - bool isUnitary(const RealScalar& prec = NumTraits::dummy_precision()) const; - - /** \returns true if each coefficients of \c *this and \a other are all exactly equal. - * \warning When using floating point scalar values you probably should rather use a - * fuzzy comparison such as isApprox() - * \sa isApprox(), operator!= */ - template - inline bool operator==(const MatrixBase& other) const - { return cwiseEqual(other).all(); } - - /** \returns true if at least one pair of coefficients of \c *this and \a other are not exactly equal to each other. - * \warning When using floating point scalar values you probably should rather use a - * fuzzy comparison such as isApprox() - * \sa isApprox(), operator== */ - template - inline bool operator!=(const MatrixBase& other) const - { return cwiseNotEqual(other).any(); } - - NoAlias noalias(); - - inline const ForceAlignedAccess forceAlignedAccess() const; - inline ForceAlignedAccess forceAlignedAccess(); - template inline typename internal::add_const_on_value_type,Derived&>::type>::type forceAlignedAccessIf() const; - template inline typename internal::conditional,Derived&>::type forceAlignedAccessIf(); - - Scalar trace() const; - -/////////// Array module /////////// - - template RealScalar lpNorm() const; - - MatrixBase& matrix() { return *this; } - const MatrixBase& matrix() const { return *this; } - - /** \returns an \link IMP_Eigen::ArrayBase Array \endlink expression of this matrix - * \sa ArrayBase::matrix() */ - ArrayWrapper array() { return derived(); } - const ArrayWrapper array() const { return derived(); } - -/////////// LU module /////////// - - const FullPivLU fullPivLu() const; - const PartialPivLU partialPivLu() const; - - #if IMP_EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS - const LU lu() const; - #endif - - #ifdef IMP_EIGEN2_SUPPORT - const LU eigen2_lu() const; - #endif - - #if IMP_EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS - const PartialPivLU lu() const; - #endif - - #ifdef IMP_EIGEN2_SUPPORT - template - void computeInverse(MatrixBase *result) const { - *result = this->inverse(); - } - #endif - - const internal::inverse_impl inverse() const; - template - void computeInverseAndDetWithCheck( - ResultType& inverse, - typename ResultType::Scalar& determinant, - bool& invertible, - const RealScalar& absDeterminantThreshold = NumTraits::dummy_precision() - ) const; - template - void computeInverseWithCheck( - ResultType& inverse, - bool& invertible, - const RealScalar& absDeterminantThreshold = NumTraits::dummy_precision() - ) const; - Scalar determinant() const; - -/////////// Cholesky module /////////// - - const LLT llt() const; - const LDLT ldlt() const; - -/////////// QR module /////////// - - const HouseholderQR householderQr() const; - const ColPivHouseholderQR colPivHouseholderQr() const; - const FullPivHouseholderQR fullPivHouseholderQr() const; - - #ifdef IMP_EIGEN2_SUPPORT - const QR qr() const; - #endif - - EigenvaluesReturnType eigenvalues() const; - RealScalar operatorNorm() const; - -/////////// SVD module /////////// - - JacobiSVD jacobiSvd(unsigned int computationOptions = 0) const; - - #ifdef IMP_EIGEN2_SUPPORT - SVD svd() const; - #endif - -/////////// Geometry module /////////// - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /// \internal helper struct to form the return type of the cross product - template struct cross_product_return_type { - typedef typename internal::scalar_product_traits::Scalar,typename internal::traits::Scalar>::ReturnType Scalar; - typedef Matrix type; - }; - #endif // IMP_EIGEN_PARSED_BY_DOXYGEN - template - typename cross_product_return_type::type - cross(const MatrixBase& other) const; - template - PlainObject cross3(const MatrixBase& other) const; - PlainObject unitOrthogonal(void) const; - Matrix eulerAngles(Index a0, Index a1, Index a2) const; - - #if IMP_EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS - ScalarMultipleReturnType operator*(const UniformScaling& s) const; - // put this as separate enum value to work around possible GCC 4.3 bug (?) - enum { HomogeneousReturnTypeDirection = ColsAtCompileTime==1?Vertical:Horizontal }; - typedef Homogeneous HomogeneousReturnType; - HomogeneousReturnType homogeneous() const; - #endif - - enum { - SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1 - }; - typedef Block::ColsAtCompileTime==1 ? SizeMinusOne : 1, - internal::traits::ColsAtCompileTime==1 ? 1 : SizeMinusOne> ConstStartMinusOne; - typedef CwiseUnaryOp::Scalar>, - const ConstStartMinusOne > HNormalizedReturnType; - - const HNormalizedReturnType hnormalized() const; - -////////// Householder module /////////// - - void makeHouseholderInPlace(Scalar& tau, RealScalar& beta); - template - void makeHouseholder(EssentialPart& essential, - Scalar& tau, RealScalar& beta) const; - template - void applyHouseholderOnTheLeft(const EssentialPart& essential, - const Scalar& tau, - Scalar* workspace); - template - void applyHouseholderOnTheRight(const EssentialPart& essential, - const Scalar& tau, - Scalar* workspace); - -///////// Jacobi module ///////// - - template - void applyOnTheLeft(Index p, Index q, const JacobiRotation& j); - template - void applyOnTheRight(Index p, Index q, const JacobiRotation& j); - -///////// SparseCore module ///////// - - template - IMP_EIGEN_STRONG_INLINE const typename SparseMatrixBase::template CwiseProductDenseReturnType::Type - cwiseProduct(const SparseMatrixBase &other) const - { - return other.cwiseProduct(derived()); - } - -///////// MatrixFunctions module ///////// - - typedef typename internal::stem_function::type StemFunction; - const MatrixExponentialReturnValue exp() const; - const MatrixFunctionReturnValue matrixFunction(StemFunction f) const; - const MatrixFunctionReturnValue cosh() const; - const MatrixFunctionReturnValue sinh() const; - const MatrixFunctionReturnValue cos() const; - const MatrixFunctionReturnValue sin() const; - const MatrixSquareRootReturnValue sqrt() const; - const MatrixLogarithmReturnValue log() const; - const MatrixPowerReturnValue pow(const RealScalar& p) const; - -#ifdef IMP_EIGEN2_SUPPORT - template - Derived& operator+=(const Flagged, 0, - EvalBeforeAssigningBit>& other); - - template - Derived& operator-=(const Flagged, 0, - EvalBeforeAssigningBit>& other); - - /** \deprecated because .lazy() is deprecated - * Overloaded for cache friendly product evaluation */ - template - Derived& lazyAssign(const Flagged& other) - { return lazyAssign(other._expression()); } - - template - const Flagged marked() const; - const Flagged lazy() const; - - inline const Cwise cwise() const; - inline Cwise cwise(); - - VectorBlock start(Index size); - const VectorBlock start(Index size) const; - VectorBlock end(Index size); - const VectorBlock end(Index size) const; - template VectorBlock start(); - template const VectorBlock start() const; - template VectorBlock end(); - template const VectorBlock end() const; - - Minor minor(Index row, Index col); - const Minor minor(Index row, Index col) const; -#endif - - protected: - MatrixBase() : Base() {} - - private: - explicit MatrixBase(int); - MatrixBase(int,int); - template explicit MatrixBase(const MatrixBase&); - protected: - // mixing arrays and matrices is not legal - template Derived& operator+=(const ArrayBase& ) - {IMP_EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;} - // mixing arrays and matrices is not legal - template Derived& operator-=(const ArrayBase& ) - {IMP_EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;} -}; - - -/*************************************************************************** -* Implementation of matrix base methods -***************************************************************************/ - -/** replaces \c *this by \c *this * \a other. - * - * \returns a reference to \c *this - * - * Example: \include MatrixBase_applyOnTheRight.cpp - * Output: \verbinclude MatrixBase_applyOnTheRight.out - */ -template -template -inline Derived& -MatrixBase::operator*=(const EigenBase &other) -{ - other.derived().applyThisOnTheRight(derived()); - return derived(); -} - -/** replaces \c *this by \c *this * \a other. It is equivalent to MatrixBase::operator*=(). - * - * Example: \include MatrixBase_applyOnTheRight.cpp - * Output: \verbinclude MatrixBase_applyOnTheRight.out - */ -template -template -inline void MatrixBase::applyOnTheRight(const EigenBase &other) -{ - other.derived().applyThisOnTheRight(derived()); -} - -/** replaces \c *this by \a other * \c *this. - * - * Example: \include MatrixBase_applyOnTheLeft.cpp - * Output: \verbinclude MatrixBase_applyOnTheLeft.out - */ -template -template -inline void MatrixBase::applyOnTheLeft(const EigenBase &other) -{ - other.derived().applyThisOnTheLeft(derived()); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_MATRIXBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/NestByValue.h b/modules/algebra/include/eigen3/Eigen/src/Core/NestByValue.h deleted file mode 100644 index ff8b154d0f..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/NestByValue.h +++ /dev/null @@ -1,111 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2006-2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_NESTBYVALUE_H -#define IMP_EIGEN_NESTBYVALUE_H - -namespace IMP_Eigen { - -/** \class NestByValue - * \ingroup Core_Module - * - * \brief Expression which must be nested by value - * - * \param ExpressionType the type of the object of which we are requiring nesting-by-value - * - * This class is the return type of MatrixBase::nestByValue() - * and most of the time this is the only way it is used. - * - * \sa MatrixBase::nestByValue() - */ - -namespace internal { -template -struct traits > : public traits -{}; -} - -template class NestByValue - : public internal::dense_xpr_base< NestByValue >::type -{ - public: - - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) - - inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} - - inline Index rows() const { return m_expression.rows(); } - inline Index cols() const { return m_expression.cols(); } - inline Index outerStride() const { return m_expression.outerStride(); } - inline Index innerStride() const { return m_expression.innerStride(); } - - inline const CoeffReturnType coeff(Index row, Index col) const - { - return m_expression.coeff(row, col); - } - - inline Scalar& coeffRef(Index row, Index col) - { - return m_expression.const_cast_derived().coeffRef(row, col); - } - - inline const CoeffReturnType coeff(Index index) const - { - return m_expression.coeff(index); - } - - inline Scalar& coeffRef(Index index) - { - return m_expression.const_cast_derived().coeffRef(index); - } - - template - inline const PacketScalar packet(Index row, Index col) const - { - return m_expression.template packet(row, col); - } - - template - inline void writePacket(Index row, Index col, const PacketScalar& x) - { - m_expression.const_cast_derived().template writePacket(row, col, x); - } - - template - inline const PacketScalar packet(Index index) const - { - return m_expression.template packet(index); - } - - template - inline void writePacket(Index index, const PacketScalar& x) - { - m_expression.const_cast_derived().template writePacket(index, x); - } - - operator const ExpressionType&() const { return m_expression; } - - protected: - const ExpressionType m_expression; -}; - -/** \returns an expression of the temporary version of *this. - */ -template -inline const NestByValue -DenseBase::nestByValue() const -{ - return NestByValue(derived()); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_NESTBYVALUE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/NoAlias.h b/modules/algebra/include/eigen3/Eigen/src/Core/NoAlias.h deleted file mode 100644 index 0ed9e3a4a5..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/NoAlias.h +++ /dev/null @@ -1,134 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_NOALIAS_H -#define IMP_EIGEN_NOALIAS_H - -namespace IMP_Eigen { - -/** \class NoAlias - * \ingroup Core_Module - * - * \brief Pseudo expression providing an operator = assuming no aliasing - * - * \param ExpressionType the type of the object on which to do the lazy assignment - * - * This class represents an expression with special assignment operators - * assuming no aliasing between the target expression and the source expression. - * More precisely it alloas to bypass the EvalBeforeAssignBit flag of the source expression. - * It is the return type of MatrixBase::noalias() - * and most of the time this is the only way it is used. - * - * \sa MatrixBase::noalias() - */ -template class StorageBase> -class NoAlias -{ - typedef typename ExpressionType::Scalar Scalar; - public: - NoAlias(ExpressionType& expression) : m_expression(expression) {} - - /** Behaves like MatrixBase::lazyAssign(other) - * \sa MatrixBase::lazyAssign() */ - template - IMP_EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase& other) - { return internal::assign_selector::run(m_expression,other.derived()); } - - /** \sa MatrixBase::operator+= */ - template - IMP_EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase& other) - { - typedef SelfCwiseBinaryOp, ExpressionType, OtherDerived> SelfAdder; - SelfAdder tmp(m_expression); - typedef typename internal::nested::type OtherDerivedNested; - typedef typename internal::remove_all::type _OtherDerivedNested; - internal::assign_selector::run(tmp,OtherDerivedNested(other.derived())); - return m_expression; - } - - /** \sa MatrixBase::operator-= */ - template - IMP_EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase& other) - { - typedef SelfCwiseBinaryOp, ExpressionType, OtherDerived> SelfAdder; - SelfAdder tmp(m_expression); - typedef typename internal::nested::type OtherDerivedNested; - typedef typename internal::remove_all::type _OtherDerivedNested; - internal::assign_selector::run(tmp,OtherDerivedNested(other.derived())); - return m_expression; - } - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - template - IMP_EIGEN_STRONG_INLINE ExpressionType& operator+=(const ProductBase& other) - { other.derived().addTo(m_expression); return m_expression; } - - template - IMP_EIGEN_STRONG_INLINE ExpressionType& operator-=(const ProductBase& other) - { other.derived().subTo(m_expression); return m_expression; } - - template - IMP_EIGEN_STRONG_INLINE ExpressionType& operator+=(const CoeffBasedProduct& other) - { return m_expression.derived() += CoeffBasedProduct(other.lhs(), other.rhs()); } - - template - IMP_EIGEN_STRONG_INLINE ExpressionType& operator-=(const CoeffBasedProduct& other) - { return m_expression.derived() -= CoeffBasedProduct(other.lhs(), other.rhs()); } - - template - ExpressionType& operator=(const ReturnByValue& func) - { return m_expression = func; } -#endif - - ExpressionType& expression() const - { - return m_expression; - } - - protected: - ExpressionType& m_expression; -}; - -/** \returns a pseudo expression of \c *this with an operator= assuming - * no aliasing between \c *this and the source expression. - * - * More precisely, noalias() allows to bypass the EvalBeforeAssignBit flag. - * Currently, even though several expressions may alias, only product - * expressions have this flag. Therefore, noalias() is only usefull when - * the source expression contains a matrix product. - * - * Here are some examples where noalias is usefull: - * \code - * D.noalias() = A * B; - * D.noalias() += A.transpose() * B; - * D.noalias() -= 2 * A * B.adjoint(); - * \endcode - * - * On the other hand the following example will lead to a \b wrong result: - * \code - * A.noalias() = A * B; - * \endcode - * because the result matrix A is also an operand of the matrix product. Therefore, - * there is no alternative than evaluating A * B in a temporary, that is the default - * behavior when you write: - * \code - * A = A * B; - * \endcode - * - * \sa class NoAlias - */ -template -NoAlias MatrixBase::noalias() -{ - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_NOALIAS_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/NumTraits.h b/modules/algebra/include/eigen3/Eigen/src/Core/NumTraits.h deleted file mode 100644 index bd4ed6ab42..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/NumTraits.h +++ /dev/null @@ -1,150 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2010 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_NUMTRAITS_H -#define IMP_EIGEN_NUMTRAITS_H - -namespace IMP_Eigen { - -/** \class NumTraits - * \ingroup Core_Module - * - * \brief Holds information about the various numeric (i.e. scalar) types allowed by Eigen. - * - * \param T the numeric type at hand - * - * This class stores enums, typedefs and static methods giving information about a numeric type. - * - * The provided data consists of: - * \li A typedef \a Real, giving the "real part" type of \a T. If \a T is already real, - * then \a Real is just a typedef to \a T. If \a T is \c std::complex then \a Real - * is a typedef to \a U. - * \li A typedef \a NonInteger, giving the type that should be used for operations producing non-integral values, - * such as quotients, square roots, etc. If \a T is a floating-point type, then this typedef just gives - * \a T again. Note however that many Eigen functions such as internal::sqrt simply refuse to - * take integers. Outside of a few cases, Eigen doesn't do automatic type promotion. Thus, this typedef is - * only intended as a helper for code that needs to explicitly promote types. - * \li A typedef \a Nested giving the type to use to nest a value inside of the expression tree. If you don't know what - * this means, just use \a T here. - * \li An enum value \a IsComplex. It is equal to 1 if \a T is a \c std::complex - * type, and to 0 otherwise. - * \li An enum value \a IsInteger. It is equal to \c 1 if \a T is an integer type such as \c int, - * and to \c 0 otherwise. - * \li Enum values ReadCost, AddCost and MulCost representing a rough estimate of the number of CPU cycles needed - * to by move / add / mul instructions respectively, assuming the data is already stored in CPU registers. - * Stay vague here. No need to do architecture-specific stuff. - * \li An enum value \a IsSigned. It is equal to \c 1 if \a T is a signed type and to 0 if \a T is unsigned. - * \li An enum value \a RequireInitialization. It is equal to \c 1 if the constructor of the numeric type \a T must - * be called, and to 0 if it is safe not to call it. Default is 0 if \a T is an arithmetic type, and 1 otherwise. - * \li An epsilon() function which, unlike std::numeric_limits::epsilon(), returns a \a Real instead of a \a T. - * \li A dummy_precision() function returning a weak epsilon value. It is mainly used as a default - * value by the fuzzy comparison operators. - * \li highest() and lowest() functions returning the highest and lowest possible values respectively. - */ - -template struct GenericNumTraits -{ - enum { - IsInteger = std::numeric_limits::is_integer, - IsSigned = std::numeric_limits::is_signed, - IsComplex = 0, - RequireInitialization = internal::is_arithmetic::value ? 0 : 1, - ReadCost = 1, - AddCost = 1, - MulCost = 1 - }; - - typedef T Real; - typedef typename internal::conditional< - IsInteger, - typename internal::conditional::type, - T - >::type NonInteger; - typedef T Nested; - - static inline Real epsilon() { return std::numeric_limits::epsilon(); } - static inline Real dummy_precision() - { - // make sure to override this for floating-point types - return Real(0); - } - static inline T highest() { return (std::numeric_limits::max)(); } - static inline T lowest() { return IsInteger ? (std::numeric_limits::min)() : (-(std::numeric_limits::max)()); } - -#ifdef IMP_EIGEN2_SUPPORT - enum { - HasFloatingPoint = !IsInteger - }; - typedef NonInteger FloatingPoint; -#endif -}; - -template struct NumTraits : GenericNumTraits -{}; - -template<> struct NumTraits - : GenericNumTraits -{ - static inline float dummy_precision() { return 1e-5f; } -}; - -template<> struct NumTraits : GenericNumTraits -{ - static inline double dummy_precision() { return 1e-12; } -}; - -template<> struct NumTraits - : GenericNumTraits -{ - static inline long double dummy_precision() { return 1e-15l; } -}; - -template struct NumTraits > - : GenericNumTraits > -{ - typedef _Real Real; - enum { - IsComplex = 1, - RequireInitialization = NumTraits<_Real>::RequireInitialization, - ReadCost = 2 * NumTraits<_Real>::ReadCost, - AddCost = 2 * NumTraits::AddCost, - MulCost = 4 * NumTraits::MulCost + 2 * NumTraits::AddCost - }; - - static inline Real epsilon() { return NumTraits::epsilon(); } - static inline Real dummy_precision() { return NumTraits::dummy_precision(); } -}; - -template -struct NumTraits > -{ - typedef Array ArrayType; - typedef typename NumTraits::Real RealScalar; - typedef Array Real; - typedef typename NumTraits::NonInteger NonIntegerScalar; - typedef Array NonInteger; - typedef ArrayType & Nested; - - enum { - IsComplex = NumTraits::IsComplex, - IsInteger = NumTraits::IsInteger, - IsSigned = NumTraits::IsSigned, - RequireInitialization = 1, - ReadCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits::ReadCost, - AddCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits::AddCost, - MulCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits::MulCost - }; - - static inline RealScalar epsilon() { return NumTraits::epsilon(); } - static inline RealScalar dummy_precision() { return NumTraits::dummy_precision(); } -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_NUMTRAITS_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/PermutationMatrix.h b/modules/algebra/include/eigen3/Eigen/src/Core/PermutationMatrix.h deleted file mode 100644 index 1b1ed4ab78..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/PermutationMatrix.h +++ /dev/null @@ -1,722 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009 Benoit Jacob -// Copyright (C) 2009-2011 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_PERMUTATIONMATRIX_H -#define IMP_EIGEN_PERMUTATIONMATRIX_H - -namespace IMP_Eigen { - -template class PermutedImpl; - -/** \class PermutationBase - * \ingroup Core_Module - * - * \brief Base class for permutations - * - * \param Derived the derived class - * - * This class is the base class for all expressions representing a permutation matrix, - * internally stored as a vector of integers. - * The convention followed here is that if \f$ \sigma \f$ is a permutation, the corresponding permutation matrix - * \f$ P_\sigma \f$ is such that if \f$ (e_1,\ldots,e_p) \f$ is the canonical basis, we have: - * \f[ P_\sigma(e_i) = e_{\sigma(i)}. \f] - * This convention ensures that for any two permutations \f$ \sigma, \tau \f$, we have: - * \f[ P_{\sigma\circ\tau} = P_\sigma P_\tau. \f] - * - * Permutation matrices are square and invertible. - * - * Notice that in addition to the member functions and operators listed here, there also are non-member - * operator* to multiply any kind of permutation object with any kind of matrix expression (MatrixBase) - * on either side. - * - * \sa class PermutationMatrix, class PermutationWrapper - */ - -namespace internal { - -template -struct permut_matrix_product_retval; -template -struct permut_sparsematrix_product_retval; -enum PermPermProduct_t {PermPermProduct}; - -} // end namespace internal - -template -class PermutationBase : public EigenBase -{ - typedef internal::traits Traits; - typedef EigenBase Base; - public: - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef typename Traits::IndicesType IndicesType; - enum { - Flags = Traits::Flags, - CoeffReadCost = Traits::CoeffReadCost, - RowsAtCompileTime = Traits::RowsAtCompileTime, - ColsAtCompileTime = Traits::ColsAtCompileTime, - MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = Traits::MaxColsAtCompileTime - }; - typedef typename Traits::Scalar Scalar; - typedef typename Traits::Index Index; - typedef Matrix - DenseMatrixType; - typedef PermutationMatrix - PlainPermutationType; - using Base::derived; - #endif - - /** Copies the other permutation into *this */ - template - Derived& operator=(const PermutationBase& other) - { - indices() = other.indices(); - return derived(); - } - - /** Assignment from the Transpositions \a tr */ - template - Derived& operator=(const TranspositionsBase& tr) - { - setIdentity(tr.size()); - for(Index k=size()-1; k>=0; --k) - applyTranspositionOnTheRight(k,tr.coeff(k)); - return derived(); - } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** This is a special case of the templated operator=. Its purpose is to - * prevent a default operator= from hiding the templated operator=. - */ - Derived& operator=(const PermutationBase& other) - { - indices() = other.indices(); - return derived(); - } - #endif - - /** \returns the number of rows */ - inline Index rows() const { return Index(indices().size()); } - - /** \returns the number of columns */ - inline Index cols() const { return Index(indices().size()); } - - /** \returns the size of a side of the respective square matrix, i.e., the number of indices */ - inline Index size() const { return Index(indices().size()); } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - template - void evalTo(MatrixBase& other) const - { - other.setZero(); - for (int i=0; i=0 && j>=0 && i=0 && j>=0 && i inverse() const - { return derived(); } - /** \returns the tranpose permutation matrix. - * - * \note \note_try_to_help_rvo - */ - inline Transpose transpose() const - { return derived(); } - - /**** multiplication helpers to hopefully get RVO ****/ - - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - protected: - template - void assignTranspose(const PermutationBase& other) - { - for (int i=0; i - void assignProduct(const Lhs& lhs, const Rhs& rhs) - { - imp_eigen_assert(lhs.cols() == rhs.rows()); - for (int i=0; i - inline PlainPermutationType operator*(const PermutationBase& other) const - { return PlainPermutationType(internal::PermPermProduct, derived(), other.derived()); } - - /** \returns the product of a permutation with another inverse permutation. - * - * \note \note_try_to_help_rvo - */ - template - inline PlainPermutationType operator*(const Transpose >& other) const - { return PlainPermutationType(internal::PermPermProduct, *this, other.eval()); } - - /** \returns the product of an inverse permutation with another permutation. - * - * \note \note_try_to_help_rvo - */ - template friend - inline PlainPermutationType operator*(const Transpose >& other, const PermutationBase& perm) - { return PlainPermutationType(internal::PermPermProduct, other.eval(), perm); } - - /** \returns the determinant of the permutation matrix, which is either 1 or -1 depending on the parity of the permutation. - * - * This function is O(\c n) procedure allocating a buffer of \c n booleans. - */ - Index determinant() const - { - Index res = 1; - Index n = size(); - Matrix mask(n); - mask.fill(false); - Index r = 0; - while(r < n) - { - // search for the next seed - while(r=n) - break; - // we got one, let's follow it until we are back to the seed - Index k0 = r++; - mask.coeffRef(k0) = true; - for(Index k=indices().coeff(k0); k!=k0; k=indices().coeff(k)) - { - mask.coeffRef(k) = true; - res = -res; - } - } - return res; - } - - protected: - -}; - -/** \class PermutationMatrix - * \ingroup Core_Module - * - * \brief Permutation matrix - * - * \param SizeAtCompileTime the number of rows/cols, or Dynamic - * \param MaxSizeAtCompileTime the maximum number of rows/cols, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it. - * \param IndexType the interger type of the indices - * - * This class represents a permutation matrix, internally stored as a vector of integers. - * - * \sa class PermutationBase, class PermutationWrapper, class DiagonalMatrix - */ - -namespace internal { -template -struct traits > - : traits > -{ - typedef IndexType Index; - typedef Matrix IndicesType; -}; -} - -template -class PermutationMatrix : public PermutationBase > -{ - typedef PermutationBase Base; - typedef internal::traits Traits; - public: - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef typename Traits::IndicesType IndicesType; - #endif - - inline PermutationMatrix() - {} - - /** Constructs an uninitialized permutation matrix of given size. - */ - inline PermutationMatrix(int size) : m_indices(size) - {} - - /** Copy constructor. */ - template - inline PermutationMatrix(const PermutationBase& other) - : m_indices(other.indices()) {} - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** Standard copy constructor. Defined only to prevent a default copy constructor - * from hiding the other templated constructor */ - inline PermutationMatrix(const PermutationMatrix& other) : m_indices(other.indices()) {} - #endif - - /** Generic constructor from expression of the indices. The indices - * array has the meaning that the permutations sends each integer i to indices[i]. - * - * \warning It is your responsibility to check that the indices array that you passes actually - * describes a permutation, i.e., each value between 0 and n-1 occurs exactly once, where n is the - * array's size. - */ - template - explicit inline PermutationMatrix(const MatrixBase& a_indices) : m_indices(a_indices) - {} - - /** Convert the Transpositions \a tr to a permutation matrix */ - template - explicit PermutationMatrix(const TranspositionsBase& tr) - : m_indices(tr.size()) - { - *this = tr; - } - - /** Copies the other permutation into *this */ - template - PermutationMatrix& operator=(const PermutationBase& other) - { - m_indices = other.indices(); - return *this; - } - - /** Assignment from the Transpositions \a tr */ - template - PermutationMatrix& operator=(const TranspositionsBase& tr) - { - return Base::operator=(tr.derived()); - } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** This is a special case of the templated operator=. Its purpose is to - * prevent a default operator= from hiding the templated operator=. - */ - PermutationMatrix& operator=(const PermutationMatrix& other) - { - m_indices = other.m_indices; - return *this; - } - #endif - - /** const version of indices(). */ - const IndicesType& indices() const { return m_indices; } - /** \returns a reference to the stored array representing the permutation. */ - IndicesType& indices() { return m_indices; } - - - /**** multiplication helpers to hopefully get RVO ****/ - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - template - PermutationMatrix(const Transpose >& other) - : m_indices(other.nestedPermutation().size()) - { - for (int i=0; i - PermutationMatrix(internal::PermPermProduct_t, const Lhs& lhs, const Rhs& rhs) - : m_indices(lhs.indices().size()) - { - Base::assignProduct(lhs,rhs); - } -#endif - - protected: - - IndicesType m_indices; -}; - - -namespace internal { -template -struct traits,_PacketAccess> > - : traits > -{ - typedef IndexType Index; - typedef Map, _PacketAccess> IndicesType; -}; -} - -template -class Map,_PacketAccess> - : public PermutationBase,_PacketAccess> > -{ - typedef PermutationBase Base; - typedef internal::traits Traits; - public: - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef typename Traits::IndicesType IndicesType; - typedef typename IndicesType::Scalar Index; - #endif - - inline Map(const Index* indicesPtr) - : m_indices(indicesPtr) - {} - - inline Map(const Index* indicesPtr, Index size) - : m_indices(indicesPtr,size) - {} - - /** Copies the other permutation into *this */ - template - Map& operator=(const PermutationBase& other) - { return Base::operator=(other.derived()); } - - /** Assignment from the Transpositions \a tr */ - template - Map& operator=(const TranspositionsBase& tr) - { return Base::operator=(tr.derived()); } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - /** This is a special case of the templated operator=. Its purpose is to - * prevent a default operator= from hiding the templated operator=. - */ - Map& operator=(const Map& other) - { - m_indices = other.m_indices; - return *this; - } - #endif - - /** const version of indices(). */ - const IndicesType& indices() const { return m_indices; } - /** \returns a reference to the stored array representing the permutation. */ - IndicesType& indices() { return m_indices; } - - protected: - - IndicesType m_indices; -}; - -/** \class PermutationWrapper - * \ingroup Core_Module - * - * \brief Class to view a vector of integers as a permutation matrix - * - * \param _IndicesType the type of the vector of integer (can be any compatible expression) - * - * This class allows to view any vector expression of integers as a permutation matrix. - * - * \sa class PermutationBase, class PermutationMatrix - */ - -struct PermutationStorage {}; - -template class TranspositionsWrapper; -namespace internal { -template -struct traits > -{ - typedef PermutationStorage StorageKind; - typedef typename _IndicesType::Scalar Scalar; - typedef typename _IndicesType::Scalar Index; - typedef _IndicesType IndicesType; - enum { - RowsAtCompileTime = _IndicesType::SizeAtCompileTime, - ColsAtCompileTime = _IndicesType::SizeAtCompileTime, - MaxRowsAtCompileTime = IndicesType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = IndicesType::MaxColsAtCompileTime, - Flags = 0, - CoeffReadCost = _IndicesType::CoeffReadCost - }; -}; -} - -template -class PermutationWrapper : public PermutationBase > -{ - typedef PermutationBase Base; - typedef internal::traits Traits; - public: - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef typename Traits::IndicesType IndicesType; - #endif - - inline PermutationWrapper(const IndicesType& a_indices) - : m_indices(a_indices) - {} - - /** const version of indices(). */ - const typename internal::remove_all::type& - indices() const { return m_indices; } - - protected: - - typename IndicesType::Nested m_indices; -}; - -/** \returns the matrix with the permutation applied to the columns. - */ -template -inline const internal::permut_matrix_product_retval -operator*(const MatrixBase& matrix, - const PermutationBase &permutation) -{ - return internal::permut_matrix_product_retval - - (permutation.derived(), matrix.derived()); -} - -/** \returns the matrix with the permutation applied to the rows. - */ -template -inline const internal::permut_matrix_product_retval - -operator*(const PermutationBase &permutation, - const MatrixBase& matrix) -{ - return internal::permut_matrix_product_retval - - (permutation.derived(), matrix.derived()); -} - -namespace internal { - -template -struct traits > -{ - typedef typename MatrixType::PlainObject ReturnType; -}; - -template -struct permut_matrix_product_retval - : public ReturnByValue > -{ - typedef typename remove_all::type MatrixTypeNestedCleaned; - typedef typename MatrixType::Index Index; - - permut_matrix_product_retval(const PermutationType& perm, const MatrixType& matrix) - : m_permutation(perm), m_matrix(matrix) - {} - - inline Index rows() const { return m_matrix.rows(); } - inline Index cols() const { return m_matrix.cols(); } - - template inline void evalTo(Dest& dst) const - { - const Index n = Side==OnTheLeft ? rows() : cols(); - // FIXME we need an is_same for expression that is not sensitive to constness. For instance - // is_same_xpr, Block >::value should be true. - const typename Dest::Scalar *dst_data = internal::extract_data(dst); - if( is_same::value - && blas_traits::HasUsableDirectAccess - && blas_traits::HasUsableDirectAccess - && dst_data!=0 && dst_data == extract_data(m_matrix)) - { - // apply the permutation inplace - Matrix mask(m_permutation.size()); - mask.fill(false); - Index r = 0; - while(r < m_permutation.size()) - { - // search for the next seed - while(r=m_permutation.size()) - break; - // we got one, let's follow it until we are back to the seed - Index k0 = r++; - Index kPrev = k0; - mask.coeffRef(k0) = true; - for(Index k=m_permutation.indices().coeff(k0); k!=k0; k=m_permutation.indices().coeff(k)) - { - Block(dst, k) - .swap(Block - (dst,((Side==OnTheLeft) ^ Transposed) ? k0 : kPrev)); - - mask.coeffRef(k) = true; - kPrev = k; - } - } - } - else - { - for(int i = 0; i < n; ++i) - { - Block - (dst, ((Side==OnTheLeft) ^ Transposed) ? m_permutation.indices().coeff(i) : i) - - = - - Block - (m_matrix, ((Side==OnTheRight) ^ Transposed) ? m_permutation.indices().coeff(i) : i); - } - } - } - - protected: - const PermutationType& m_permutation; - typename MatrixType::Nested m_matrix; -}; - -/* Template partial specialization for transposed/inverse permutations */ - -template -struct traits > > - : traits -{}; - -} // end namespace internal - -template -class Transpose > - : public EigenBase > > -{ - typedef Derived PermutationType; - typedef typename PermutationType::IndicesType IndicesType; - typedef typename PermutationType::PlainPermutationType PlainPermutationType; - public: - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - typedef internal::traits Traits; - typedef typename Derived::DenseMatrixType DenseMatrixType; - enum { - Flags = Traits::Flags, - CoeffReadCost = Traits::CoeffReadCost, - RowsAtCompileTime = Traits::RowsAtCompileTime, - ColsAtCompileTime = Traits::ColsAtCompileTime, - MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = Traits::MaxColsAtCompileTime - }; - typedef typename Traits::Scalar Scalar; - #endif - - Transpose(const PermutationType& p) : m_permutation(p) {} - - inline int rows() const { return m_permutation.rows(); } - inline int cols() const { return m_permutation.cols(); } - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - template - void evalTo(MatrixBase& other) const - { - other.setZero(); - for (int i=0; i friend - inline const internal::permut_matrix_product_retval - operator*(const MatrixBase& matrix, const Transpose& trPerm) - { - return internal::permut_matrix_product_retval(trPerm.m_permutation, matrix.derived()); - } - - /** \returns the matrix with the inverse permutation applied to the rows. - */ - template - inline const internal::permut_matrix_product_retval - operator*(const MatrixBase& matrix) const - { - return internal::permut_matrix_product_retval(m_permutation, matrix.derived()); - } - - const PermutationType& nestedPermutation() const { return m_permutation; } - - protected: - const PermutationType& m_permutation; -}; - -template -const PermutationWrapper MatrixBase::asPermutation() const -{ - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_PERMUTATIONMATRIX_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/PlainObjectBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/PlainObjectBase.h deleted file mode 100644 index 4e91bd6b39..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/PlainObjectBase.h +++ /dev/null @@ -1,822 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2009 Gael Guennebaud -// Copyright (C) 2006-2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_DENSESTORAGEBASE_H -#define IMP_EIGEN_DENSESTORAGEBASE_H - -#if defined(IMP_EIGEN_INITIALIZE_MATRICES_BY_ZERO) -# define IMP_EIGEN_INITIALIZE_COEFFS -# define IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED for(int i=0;i::quiet_NaN(); -#else -# undef IMP_EIGEN_INITIALIZE_COEFFS -# define IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED -#endif - -namespace IMP_Eigen { - -namespace internal { - -template struct check_rows_cols_for_overflow { - template - static IMP_EIGEN_ALWAYS_INLINE void run(Index, Index) - { - } -}; - -template<> struct check_rows_cols_for_overflow { - template - static IMP_EIGEN_ALWAYS_INLINE void run(Index rows, Index cols) - { - // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242 - // we assume Index is signed - Index max_index = (size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed - bool error = (rows == 0 || cols == 0) ? false - : (rows > max_index / cols); - if (error) - throw_std_bad_alloc(); - } -}; - -template -struct conservative_resize_like_impl; - -template struct matrix_swap_impl; - -} // end namespace internal - -/** \class PlainObjectBase - * \brief %Dense storage base class for matrices and arrays. - * - * This class can be extended with the help of the plugin mechanism described on the page - * \ref TopicCustomizingEigen by defining the preprocessor symbol \c IMP_EIGEN_PLAINOBJECTBASE_PLUGIN. - * - * \sa \ref TopicClassHierarchy - */ -#ifdef IMP_EIGEN_PARSED_BY_DOXYGEN -namespace internal { - -// this is a warkaround to doxygen not being able to understand the inheritence logic -// when it is hidden by the dense_xpr_base helper struct. -template struct dense_xpr_base_dispatcher_for_doxygen;// : public MatrixBase {}; -/** This class is just a workaround for Doxygen and it does not not actually exist. */ -template -struct dense_xpr_base_dispatcher_for_doxygen > - : public MatrixBase > {}; -/** This class is just a workaround for Doxygen and it does not not actually exist. */ -template -struct dense_xpr_base_dispatcher_for_doxygen > - : public ArrayBase > {}; - -} // namespace internal - -template -class PlainObjectBase : public internal::dense_xpr_base_dispatcher_for_doxygen -#else -template -class PlainObjectBase : public internal::dense_xpr_base::type -#endif -{ - public: - enum { Options = internal::traits::Options }; - typedef typename internal::dense_xpr_base::type Base; - - typedef typename internal::traits::StorageKind StorageKind; - typedef typename internal::traits::Index Index; - typedef typename internal::traits::Scalar Scalar; - typedef typename internal::packet_traits::type PacketScalar; - typedef typename NumTraits::Real RealScalar; - typedef Derived DenseType; - - using Base::RowsAtCompileTime; - using Base::ColsAtCompileTime; - using Base::SizeAtCompileTime; - using Base::MaxRowsAtCompileTime; - using Base::MaxColsAtCompileTime; - using Base::MaxSizeAtCompileTime; - using Base::IsVectorAtCompileTime; - using Base::Flags; - - template friend class IMP_Eigen::Map; - friend class IMP_Eigen::Map; - typedef IMP_Eigen::Map MapType; - friend class IMP_Eigen::Map; - typedef const IMP_Eigen::Map ConstMapType; - friend class IMP_Eigen::Map; - typedef IMP_Eigen::Map AlignedMapType; - friend class IMP_Eigen::Map; - typedef const IMP_Eigen::Map ConstAlignedMapType; - template struct StridedMapType { typedef IMP_Eigen::Map type; }; - template struct StridedConstMapType { typedef IMP_Eigen::Map type; }; - template struct StridedAlignedMapType { typedef IMP_Eigen::Map type; }; - template struct StridedConstAlignedMapType { typedef IMP_Eigen::Map type; }; - - protected: - DenseStorage m_storage; - - public: - enum { NeedsToAlign = SizeAtCompileTime != Dynamic && (internal::traits::Flags & AlignedBit) != 0 }; - IMP_EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) - - Base& base() { return *static_cast(this); } - const Base& base() const { return *static_cast(this); } - - IMP_EIGEN_STRONG_INLINE Index rows() const { return m_storage.rows(); } - IMP_EIGEN_STRONG_INLINE Index cols() const { return m_storage.cols(); } - - IMP_EIGEN_STRONG_INLINE const Scalar& coeff(Index rowId, Index colId) const - { - if(Flags & RowMajorBit) - return m_storage.data()[colId + rowId * m_storage.cols()]; - else // column-major - return m_storage.data()[rowId + colId * m_storage.rows()]; - } - - IMP_EIGEN_STRONG_INLINE const Scalar& coeff(Index index) const - { - return m_storage.data()[index]; - } - - IMP_EIGEN_STRONG_INLINE Scalar& coeffRef(Index rowId, Index colId) - { - if(Flags & RowMajorBit) - return m_storage.data()[colId + rowId * m_storage.cols()]; - else // column-major - return m_storage.data()[rowId + colId * m_storage.rows()]; - } - - IMP_EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) - { - return m_storage.data()[index]; - } - - IMP_EIGEN_STRONG_INLINE const Scalar& coeffRef(Index rowId, Index colId) const - { - if(Flags & RowMajorBit) - return m_storage.data()[colId + rowId * m_storage.cols()]; - else // column-major - return m_storage.data()[rowId + colId * m_storage.rows()]; - } - - IMP_EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const - { - return m_storage.data()[index]; - } - - /** \internal */ - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const - { - return internal::ploadt - (m_storage.data() + (Flags & RowMajorBit - ? colId + rowId * m_storage.cols() - : rowId + colId * m_storage.rows())); - } - - /** \internal */ - template - IMP_EIGEN_STRONG_INLINE PacketScalar packet(Index index) const - { - return internal::ploadt(m_storage.data() + index); - } - - /** \internal */ - template - IMP_EIGEN_STRONG_INLINE void writePacket(Index rowId, Index colId, const PacketScalar& val) - { - internal::pstoret - (m_storage.data() + (Flags & RowMajorBit - ? colId + rowId * m_storage.cols() - : rowId + colId * m_storage.rows()), val); - } - - /** \internal */ - template - IMP_EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar& val) - { - internal::pstoret(m_storage.data() + index, val); - } - - /** \returns a const pointer to the data array of this matrix */ - IMP_EIGEN_STRONG_INLINE const Scalar *data() const - { return m_storage.data(); } - - /** \returns a pointer to the data array of this matrix */ - IMP_EIGEN_STRONG_INLINE Scalar *data() - { return m_storage.data(); } - - /** Resizes \c *this to a \a rows x \a cols matrix. - * - * This method is intended for dynamic-size matrices, although it is legal to call it on any - * matrix as long as fixed dimensions are left unchanged. If you only want to change the number - * of rows and/or of columns, you can use resize(NoChange_t, Index), resize(Index, NoChange_t). - * - * If the current number of coefficients of \c *this exactly matches the - * product \a rows * \a cols, then no memory allocation is performed and - * the current values are left unchanged. In all other cases, including - * shrinking, the data is reallocated and all previous values are lost. - * - * Example: \include Matrix_resize_int_int.cpp - * Output: \verbinclude Matrix_resize_int_int.out - * - * \sa resize(Index) for vectors, resize(NoChange_t, Index), resize(Index, NoChange_t) - */ - IMP_EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols) - { - imp_eigen_assert( IMP_EIGEN_IMPLIES(RowsAtCompileTime!=Dynamic,nbRows==RowsAtCompileTime) - && IMP_EIGEN_IMPLIES(ColsAtCompileTime!=Dynamic,nbCols==ColsAtCompileTime) - && IMP_EIGEN_IMPLIES(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic,nbRows<=MaxRowsAtCompileTime) - && IMP_EIGEN_IMPLIES(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic,nbCols<=MaxColsAtCompileTime) - && nbRows>=0 && nbCols>=0 && "Invalid sizes when resizing a matrix or array."); - internal::check_rows_cols_for_overflow::run(nbRows, nbCols); - #ifdef IMP_EIGEN_INITIALIZE_COEFFS - Index size = nbRows*nbCols; - bool size_changed = size != this->size(); - m_storage.resize(size, nbRows, nbCols); - if(size_changed) IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - #else - internal::check_rows_cols_for_overflow::run(nbRows, nbCols); - m_storage.resize(nbRows*nbCols, nbRows, nbCols); - #endif - } - - /** Resizes \c *this to a vector of length \a size - * - * \only_for_vectors. This method does not work for - * partially dynamic matrices when the static dimension is anything other - * than 1. For example it will not work with Matrix. - * - * Example: \include Matrix_resize_int.cpp - * Output: \verbinclude Matrix_resize_int.out - * - * \sa resize(Index,Index), resize(NoChange_t, Index), resize(Index, NoChange_t) - */ - inline void resize(Index size) - { - IMP_EIGEN_STATIC_ASSERT_VECTOR_ONLY(PlainObjectBase) - imp_eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime==Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0); - #ifdef IMP_EIGEN_INITIALIZE_COEFFS - bool size_changed = size != this->size(); - #endif - if(RowsAtCompileTime == 1) - m_storage.resize(size, 1, size); - else - m_storage.resize(size, size, 1); - #ifdef IMP_EIGEN_INITIALIZE_COEFFS - if(size_changed) IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - #endif - } - - /** Resizes the matrix, changing only the number of columns. For the parameter of type NoChange_t, just pass the special value \c NoChange - * as in the example below. - * - * Example: \include Matrix_resize_NoChange_int.cpp - * Output: \verbinclude Matrix_resize_NoChange_int.out - * - * \sa resize(Index,Index) - */ - inline void resize(NoChange_t, Index nbCols) - { - resize(rows(), nbCols); - } - - /** Resizes the matrix, changing only the number of rows. For the parameter of type NoChange_t, just pass the special value \c NoChange - * as in the example below. - * - * Example: \include Matrix_resize_int_NoChange.cpp - * Output: \verbinclude Matrix_resize_int_NoChange.out - * - * \sa resize(Index,Index) - */ - inline void resize(Index nbRows, NoChange_t) - { - resize(nbRows, cols()); - } - - /** Resizes \c *this to have the same dimensions as \a other. - * Takes care of doing all the checking that's needed. - * - * Note that copying a row-vector into a vector (and conversely) is allowed. - * The resizing, if any, is then done in the appropriate way so that row-vectors - * remain row-vectors and vectors remain vectors. - */ - template - IMP_EIGEN_STRONG_INLINE void resizeLike(const EigenBase& _other) - { - const OtherDerived& other = _other.derived(); - internal::check_rows_cols_for_overflow::run(Index(other.rows()), Index(other.cols())); - const Index othersize = Index(other.rows())*Index(other.cols()); - if(RowsAtCompileTime == 1) - { - imp_eigen_assert(other.rows() == 1 || other.cols() == 1); - resize(1, othersize); - } - else if(ColsAtCompileTime == 1) - { - imp_eigen_assert(other.rows() == 1 || other.cols() == 1); - resize(othersize, 1); - } - else resize(other.rows(), other.cols()); - } - - /** Resizes the matrix to \a rows x \a cols while leaving old values untouched. - * - * The method is intended for matrices of dynamic size. If you only want to change the number - * of rows and/or of columns, you can use conservativeResize(NoChange_t, Index) or - * conservativeResize(Index, NoChange_t). - * - * Matrices are resized relative to the top-left element. In case values need to be - * appended to the matrix they will be uninitialized. - */ - IMP_EIGEN_STRONG_INLINE void conservativeResize(Index nbRows, Index nbCols) - { - internal::conservative_resize_like_impl::run(*this, nbRows, nbCols); - } - - /** Resizes the matrix to \a rows x \a cols while leaving old values untouched. - * - * As opposed to conservativeResize(Index rows, Index cols), this version leaves - * the number of columns unchanged. - * - * In case the matrix is growing, new rows will be uninitialized. - */ - IMP_EIGEN_STRONG_INLINE void conservativeResize(Index nbRows, NoChange_t) - { - // Note: see the comment in conservativeResize(Index,Index) - conservativeResize(nbRows, cols()); - } - - /** Resizes the matrix to \a rows x \a cols while leaving old values untouched. - * - * As opposed to conservativeResize(Index rows, Index cols), this version leaves - * the number of rows unchanged. - * - * In case the matrix is growing, new columns will be uninitialized. - */ - IMP_EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index nbCols) - { - // Note: see the comment in conservativeResize(Index,Index) - conservativeResize(rows(), nbCols); - } - - /** Resizes the vector to \a size while retaining old values. - * - * \only_for_vectors. This method does not work for - * partially dynamic matrices when the static dimension is anything other - * than 1. For example it will not work with Matrix. - * - * When values are appended, they will be uninitialized. - */ - IMP_EIGEN_STRONG_INLINE void conservativeResize(Index size) - { - internal::conservative_resize_like_impl::run(*this, size); - } - - /** Resizes the matrix to \a rows x \a cols of \c other, while leaving old values untouched. - * - * The method is intended for matrices of dynamic size. If you only want to change the number - * of rows and/or of columns, you can use conservativeResize(NoChange_t, Index) or - * conservativeResize(Index, NoChange_t). - * - * Matrices are resized relative to the top-left element. In case values need to be - * appended to the matrix they will copied from \c other. - */ - template - IMP_EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase& other) - { - internal::conservative_resize_like_impl::run(*this, other); - } - - /** This is a special case of the templated operator=. Its purpose is to - * prevent a default operator= from hiding the templated operator=. - */ - IMP_EIGEN_STRONG_INLINE Derived& operator=(const PlainObjectBase& other) - { - return _set(other); - } - - /** \sa MatrixBase::lazyAssign() */ - template - IMP_EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase& other) - { - _resize_to_match(other); - return Base::lazyAssign(other.derived()); - } - - template - IMP_EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue& func) - { - resize(func.rows(), func.cols()); - return Base::operator=(func); - } - - IMP_EIGEN_STRONG_INLINE PlainObjectBase() : m_storage() - { -// _check_template_params(); -// IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - // FIXME is it still needed ? - /** \internal */ - PlainObjectBase(internal::constructor_without_unaligned_array_assert) - : m_storage(internal::constructor_without_unaligned_array_assert()) - { -// _check_template_params(); IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } -#endif - -#ifdef IMP_EIGEN_HAVE_RVALUE_REFERENCES - PlainObjectBase(PlainObjectBase&& other) - : m_storage( std::move(other.m_storage) ) - { - } - - PlainObjectBase& operator=(PlainObjectBase&& other) - { - using std::swap; - swap(m_storage, other.m_storage); - return *this; - } -#endif - - /** Copy constructor */ - IMP_EIGEN_STRONG_INLINE PlainObjectBase(const PlainObjectBase& other) - : m_storage() - { - _check_template_params(); - lazyAssign(other); - } - - template - IMP_EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase &other) - : m_storage() - { - _check_template_params(); - lazyAssign(other); - } - - IMP_EIGEN_STRONG_INLINE PlainObjectBase(Index a_size, Index nbRows, Index nbCols) - : m_storage(a_size, nbRows, nbCols) - { -// _check_template_params(); -// IMP_EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED - } - - /** \copydoc MatrixBase::operator=(const EigenBase&) - */ - template - IMP_EIGEN_STRONG_INLINE Derived& operator=(const EigenBase &other) - { - _resize_to_match(other); - Base::operator=(other.derived()); - return this->derived(); - } - - /** \sa MatrixBase::operator=(const EigenBase&) */ - template - IMP_EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase &other) - : m_storage(Index(other.derived().rows()) * Index(other.derived().cols()), other.derived().rows(), other.derived().cols()) - { - _check_template_params(); - internal::check_rows_cols_for_overflow::run(other.derived().rows(), other.derived().cols()); - Base::operator=(other.derived()); - } - - /** \name Map - * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects, - * while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned - * \a data pointers. - * - * \see class Map - */ - //@{ - static inline ConstMapType Map(const Scalar* data) - { return ConstMapType(data); } - static inline MapType Map(Scalar* data) - { return MapType(data); } - static inline ConstMapType Map(const Scalar* data, Index size) - { return ConstMapType(data, size); } - static inline MapType Map(Scalar* data, Index size) - { return MapType(data, size); } - static inline ConstMapType Map(const Scalar* data, Index rows, Index cols) - { return ConstMapType(data, rows, cols); } - static inline MapType Map(Scalar* data, Index rows, Index cols) - { return MapType(data, rows, cols); } - - static inline ConstAlignedMapType MapAligned(const Scalar* data) - { return ConstAlignedMapType(data); } - static inline AlignedMapType MapAligned(Scalar* data) - { return AlignedMapType(data); } - static inline ConstAlignedMapType MapAligned(const Scalar* data, Index size) - { return ConstAlignedMapType(data, size); } - static inline AlignedMapType MapAligned(Scalar* data, Index size) - { return AlignedMapType(data, size); } - static inline ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols) - { return ConstAlignedMapType(data, rows, cols); } - static inline AlignedMapType MapAligned(Scalar* data, Index rows, Index cols) - { return AlignedMapType(data, rows, cols); } - - template - static inline typename StridedConstMapType >::type Map(const Scalar* data, const Stride& stride) - { return typename StridedConstMapType >::type(data, stride); } - template - static inline typename StridedMapType >::type Map(Scalar* data, const Stride& stride) - { return typename StridedMapType >::type(data, stride); } - template - static inline typename StridedConstMapType >::type Map(const Scalar* data, Index size, const Stride& stride) - { return typename StridedConstMapType >::type(data, size, stride); } - template - static inline typename StridedMapType >::type Map(Scalar* data, Index size, const Stride& stride) - { return typename StridedMapType >::type(data, size, stride); } - template - static inline typename StridedConstMapType >::type Map(const Scalar* data, Index rows, Index cols, const Stride& stride) - { return typename StridedConstMapType >::type(data, rows, cols, stride); } - template - static inline typename StridedMapType >::type Map(Scalar* data, Index rows, Index cols, const Stride& stride) - { return typename StridedMapType >::type(data, rows, cols, stride); } - - template - static inline typename StridedConstAlignedMapType >::type MapAligned(const Scalar* data, const Stride& stride) - { return typename StridedConstAlignedMapType >::type(data, stride); } - template - static inline typename StridedAlignedMapType >::type MapAligned(Scalar* data, const Stride& stride) - { return typename StridedAlignedMapType >::type(data, stride); } - template - static inline typename StridedConstAlignedMapType >::type MapAligned(const Scalar* data, Index size, const Stride& stride) - { return typename StridedConstAlignedMapType >::type(data, size, stride); } - template - static inline typename StridedAlignedMapType >::type MapAligned(Scalar* data, Index size, const Stride& stride) - { return typename StridedAlignedMapType >::type(data, size, stride); } - template - static inline typename StridedConstAlignedMapType >::type MapAligned(const Scalar* data, Index rows, Index cols, const Stride& stride) - { return typename StridedConstAlignedMapType >::type(data, rows, cols, stride); } - template - static inline typename StridedAlignedMapType >::type MapAligned(Scalar* data, Index rows, Index cols, const Stride& stride) - { return typename StridedAlignedMapType >::type(data, rows, cols, stride); } - //@} - - using Base::setConstant; - Derived& setConstant(Index size, const Scalar& value); - Derived& setConstant(Index rows, Index cols, const Scalar& value); - - using Base::setZero; - Derived& setZero(Index size); - Derived& setZero(Index rows, Index cols); - - using Base::setOnes; - Derived& setOnes(Index size); - Derived& setOnes(Index rows, Index cols); - - using Base::setRandom; - Derived& setRandom(Index size); - Derived& setRandom(Index rows, Index cols); - - #ifdef IMP_EIGEN_PLAINOBJECTBASE_PLUGIN - #include IMP_EIGEN_PLAINOBJECTBASE_PLUGIN - #endif - - protected: - /** \internal Resizes *this in preparation for assigning \a other to it. - * Takes care of doing all the checking that's needed. - * - * Note that copying a row-vector into a vector (and conversely) is allowed. - * The resizing, if any, is then done in the appropriate way so that row-vectors - * remain row-vectors and vectors remain vectors. - */ - template - IMP_EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase& other) - { - #ifdef IMP_EIGEN_NO_AUTOMATIC_RESIZING - imp_eigen_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size()) - : (rows() == other.rows() && cols() == other.cols()))) - && "Size mismatch. Automatic resizing is disabled because IMP_EIGEN_NO_AUTOMATIC_RESIZING is defined"); - IMP_EIGEN_ONLY_USED_FOR_DEBUG(other); - if(this->size()==0) - resizeLike(other); - #else - resizeLike(other); - #endif - } - - /** - * \brief Copies the value of the expression \a other into \c *this with automatic resizing. - * - * *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized), - * it will be initialized. - * - * Note that copying a row-vector into a vector (and conversely) is allowed. - * The resizing, if any, is then done in the appropriate way so that row-vectors - * remain row-vectors and vectors remain vectors. - * - * \sa operator=(const MatrixBase&), _set_noalias() - * - * \internal - */ - template - IMP_EIGEN_STRONG_INLINE Derived& _set(const DenseBase& other) - { - _set_selector(other.derived(), typename internal::conditional(int(OtherDerived::Flags) & EvalBeforeAssigningBit), internal::true_type, internal::false_type>::type()); - return this->derived(); - } - - template - IMP_EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const internal::true_type&) { _set_noalias(other.eval()); } - - template - IMP_EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const internal::false_type&) { _set_noalias(other); } - - /** \internal Like _set() but additionally makes the assumption that no aliasing effect can happen (which - * is the case when creating a new matrix) so one can enforce lazy evaluation. - * - * \sa operator=(const MatrixBase&), _set() - */ - template - IMP_EIGEN_STRONG_INLINE Derived& _set_noalias(const DenseBase& other) - { - // I don't think we need this resize call since the lazyAssign will anyways resize - // and lazyAssign will be called by the assign selector. - //_resize_to_match(other); - // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because - // it wouldn't allow to copy a row-vector into a column-vector. - return internal::assign_selector::run(this->derived(), other.derived()); - } - - template - IMP_EIGEN_STRONG_INLINE void _init2(Index nbRows, Index nbCols, typename internal::enable_if::type* = 0) - { - IMP_EIGEN_STATIC_ASSERT(bool(NumTraits::IsInteger) && - bool(NumTraits::IsInteger), - FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED) - resize(nbRows,nbCols); - } - template - IMP_EIGEN_STRONG_INLINE void _init2(const Scalar& val0, const Scalar& val1, typename internal::enable_if::type* = 0) - { - IMP_EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2) - m_storage.data()[0] = val0; - m_storage.data()[1] = val1; - } - - template - friend struct internal::matrix_swap_impl; - - /** \internal generic implementation of swap for dense storage since for dynamic-sized matrices of same type it is enough to swap the - * data pointers. - */ - template - void _swap(DenseBase const & other) - { - enum { SwapPointers = internal::is_same::value && Base::SizeAtCompileTime==Dynamic }; - internal::matrix_swap_impl::run(this->derived(), other.const_cast_derived()); - } - - public: -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - static IMP_EIGEN_STRONG_INLINE void _check_template_params() - { - IMP_EIGEN_STATIC_ASSERT((IMP_EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (Options&RowMajor)==RowMajor) - && IMP_EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, (Options&RowMajor)==0) - && ((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0)) - && ((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0)) - && ((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0)) - && ((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0)) - && (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic) - && (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic) - && (Options & (DontAlign|RowMajor)) == Options), - INVALID_MATRIX_TEMPLATE_PARAMETERS) - } -#endif - -private: - enum { ThisConstantIsPrivateInPlainObjectBase }; -}; - -namespace internal { - -template -struct conservative_resize_like_impl -{ - typedef typename Derived::Index Index; - static void run(DenseBase& _this, Index rows, Index cols) - { - if (_this.rows() == rows && _this.cols() == cols) return; - IMP_EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived) - - if ( ( Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows - (!Derived::IsRowMajor && _this.rows() == rows) ) // column-major and we change only the number of columns - { - internal::check_rows_cols_for_overflow::run(rows, cols); - _this.derived().m_storage.conservativeResize(rows*cols,rows,cols); - } - else - { - // The storage order does not allow us to use reallocation. - typename Derived::PlainObject tmp(rows,cols); - const Index common_rows = (std::min)(rows, _this.rows()); - const Index common_cols = (std::min)(cols, _this.cols()); - tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols); - _this.derived().swap(tmp); - } - } - - static void run(DenseBase& _this, const DenseBase& other) - { - if (_this.rows() == other.rows() && _this.cols() == other.cols()) return; - - // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index), - // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the - // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or - // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like - // IMP_EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and IMP_EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good. - IMP_EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived) - IMP_EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived) - - if ( ( Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows - (!Derived::IsRowMajor && _this.rows() == other.rows()) ) // column-major and we change only the number of columns - { - const Index new_rows = other.rows() - _this.rows(); - const Index new_cols = other.cols() - _this.cols(); - _this.derived().m_storage.conservativeResize(other.size(),other.rows(),other.cols()); - if (new_rows>0) - _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows); - else if (new_cols>0) - _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols); - } - else - { - // The storage order does not allow us to use reallocation. - typename Derived::PlainObject tmp(other); - const Index common_rows = (std::min)(tmp.rows(), _this.rows()); - const Index common_cols = (std::min)(tmp.cols(), _this.cols()); - tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols); - _this.derived().swap(tmp); - } - } -}; - -// Here, the specialization for vectors inherits from the general matrix case -// to allow calling .conservativeResize(rows,cols) on vectors. -template -struct conservative_resize_like_impl - : conservative_resize_like_impl -{ - using conservative_resize_like_impl::run; - - typedef typename Derived::Index Index; - static void run(DenseBase& _this, Index size) - { - const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size; - const Index new_cols = Derived::RowsAtCompileTime==1 ? size : 1; - _this.derived().m_storage.conservativeResize(size,new_rows,new_cols); - } - - static void run(DenseBase& _this, const DenseBase& other) - { - if (_this.rows() == other.rows() && _this.cols() == other.cols()) return; - - const Index num_new_elements = other.size() - _this.size(); - - const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows(); - const Index new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1; - _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols); - - if (num_new_elements > 0) - _this.tail(num_new_elements) = other.tail(num_new_elements); - } -}; - -template -struct matrix_swap_impl -{ - static inline void run(MatrixTypeA& a, MatrixTypeB& b) - { - a.base().swap(b); - } -}; - -template -struct matrix_swap_impl -{ - static inline void run(MatrixTypeA& a, MatrixTypeB& b) - { - static_cast(a).m_storage.swap(static_cast(b).m_storage); - } -}; - -} // end namespace internal - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_DENSESTORAGEBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/ProductBase.h b/modules/algebra/include/eigen3/Eigen/src/Core/ProductBase.h deleted file mode 100644 index 9979dce174..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/ProductBase.h +++ /dev/null @@ -1,290 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_PRODUCTBASE_H -#define IMP_EIGEN_PRODUCTBASE_H - -namespace IMP_Eigen { - -/** \class ProductBase - * \ingroup Core_Module - * - */ - -namespace internal { -template -struct traits > -{ - typedef MatrixXpr XprKind; - typedef typename remove_all<_Lhs>::type Lhs; - typedef typename remove_all<_Rhs>::type Rhs; - typedef typename scalar_product_traits::ReturnType Scalar; - typedef typename promote_storage_type::StorageKind, - typename traits::StorageKind>::ret StorageKind; - typedef typename promote_index_type::Index, - typename traits::Index>::type Index; - enum { - RowsAtCompileTime = traits::RowsAtCompileTime, - ColsAtCompileTime = traits::ColsAtCompileTime, - MaxRowsAtCompileTime = traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = traits::MaxColsAtCompileTime, - Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0) - | EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, - // Note that EvalBeforeNestingBit and NestByRefBit - // are not used in practice because nested is overloaded for products - CoeffReadCost = 0 // FIXME why is it needed ? - }; -}; -} - -#define IMP_EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived) \ - typedef ProductBase Base; \ - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ - typedef typename Base::LhsNested LhsNested; \ - typedef typename Base::_LhsNested _LhsNested; \ - typedef typename Base::LhsBlasTraits LhsBlasTraits; \ - typedef typename Base::ActualLhsType ActualLhsType; \ - typedef typename Base::_ActualLhsType _ActualLhsType; \ - typedef typename Base::RhsNested RhsNested; \ - typedef typename Base::_RhsNested _RhsNested; \ - typedef typename Base::RhsBlasTraits RhsBlasTraits; \ - typedef typename Base::ActualRhsType ActualRhsType; \ - typedef typename Base::_ActualRhsType _ActualRhsType; \ - using Base::m_lhs; \ - using Base::m_rhs; - -template -class ProductBase : public MatrixBase -{ - public: - typedef MatrixBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(ProductBase) - - typedef typename Lhs::Nested LhsNested; - typedef typename internal::remove_all::type _LhsNested; - typedef internal::blas_traits<_LhsNested> LhsBlasTraits; - typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType; - typedef typename internal::remove_all::type _ActualLhsType; - typedef typename internal::traits::Scalar LhsScalar; - - typedef typename Rhs::Nested RhsNested; - typedef typename internal::remove_all::type _RhsNested; - typedef internal::blas_traits<_RhsNested> RhsBlasTraits; - typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; - typedef typename internal::remove_all::type _ActualRhsType; - typedef typename internal::traits::Scalar RhsScalar; - - // Diagonal of a product: no need to evaluate the arguments because they are going to be evaluated only once - typedef CoeffBasedProduct FullyLazyCoeffBaseProductType; - - public: - -#ifndef IMP_EIGEN_NO_MALLOC - typedef typename Base::PlainObject BasePlainObject; - typedef Matrix DynPlainObject; - typedef typename internal::conditional<(BasePlainObject::SizeAtCompileTime==Dynamic) || (BasePlainObject::SizeAtCompileTime*int(sizeof(Scalar)) < int(IMP_EIGEN_STACK_ALLOCATION_LIMIT)), - BasePlainObject, DynPlainObject>::type PlainObject; -#else - typedef typename Base::PlainObject PlainObject; -#endif - - ProductBase(const Lhs& a_lhs, const Rhs& a_rhs) - : m_lhs(a_lhs), m_rhs(a_rhs) - { - imp_eigen_assert(a_lhs.cols() == a_rhs.rows() - && "invalid matrix product" - && "if you wanted a coeff-wise or a dot product use the respective explicit functions"); - } - - inline Index rows() const { return m_lhs.rows(); } - inline Index cols() const { return m_rhs.cols(); } - - template - inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst,Scalar(1)); } - - template - inline void addTo(Dest& dst) const { scaleAndAddTo(dst,Scalar(1)); } - - template - inline void subTo(Dest& dst) const { scaleAndAddTo(dst,Scalar(-1)); } - - template - inline void scaleAndAddTo(Dest& dst, const Scalar& alpha) const { derived().scaleAndAddTo(dst,alpha); } - - const _LhsNested& lhs() const { return m_lhs; } - const _RhsNested& rhs() const { return m_rhs; } - - // Implicit conversion to the nested type (trigger the evaluation of the product) - operator const PlainObject& () const - { - m_result.resize(m_lhs.rows(), m_rhs.cols()); - derived().evalTo(m_result); - return m_result; - } - - const Diagonal diagonal() const - { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); } - - template - const Diagonal diagonal() const - { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); } - - const Diagonal diagonal(Index index) const - { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } - - // restrict coeff accessors to 1x1 expressions. No need to care about mutators here since this isnt a Lvalue expression - typename Base::CoeffReturnType coeff(Index row, Index col) const - { -#ifdef IMP_EIGEN2_SUPPORT - return lhs().row(row).cwiseProduct(rhs().col(col).transpose()).sum(); -#else - IMP_EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) - imp_eigen_assert(this->rows() == 1 && this->cols() == 1); - Matrix result = *this; - return result.coeff(row,col); -#endif - } - - typename Base::CoeffReturnType coeff(Index i) const - { - IMP_EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) - imp_eigen_assert(this->rows() == 1 && this->cols() == 1); - Matrix result = *this; - return result.coeff(i); - } - - const Scalar& coeffRef(Index row, Index col) const - { - IMP_EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) - imp_eigen_assert(this->rows() == 1 && this->cols() == 1); - return derived().coeffRef(row,col); - } - - const Scalar& coeffRef(Index i) const - { - IMP_EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) - imp_eigen_assert(this->rows() == 1 && this->cols() == 1); - return derived().coeffRef(i); - } - - protected: - - LhsNested m_lhs; - RhsNested m_rhs; - - mutable PlainObject m_result; -}; - -// here we need to overload the nested rule for products -// such that the nested type is a const reference to a plain matrix -namespace internal { -template -struct nested, N, PlainObject> -{ - typedef typename GeneralProduct::PlainObject const& type; -}; -template -struct nested, N, PlainObject> -{ - typedef typename GeneralProduct::PlainObject const& type; -}; -} - -template -class ScaledProduct; - -// Note that these two operator* functions are not defined as member -// functions of ProductBase, because, otherwise we would have to -// define all overloads defined in MatrixBase. Furthermore, Using -// "using Base::operator*" would not work with MSVC. -// -// Also note that here we accept any compatible scalar types -template -const ScaledProduct -operator*(const ProductBase& prod, const typename Derived::Scalar& x) -{ return ScaledProduct(prod.derived(), x); } - -template -typename internal::enable_if::value, - const ScaledProduct >::type -operator*(const ProductBase& prod, const typename Derived::RealScalar& x) -{ return ScaledProduct(prod.derived(), x); } - - -template -const ScaledProduct -operator*(const typename Derived::Scalar& x,const ProductBase& prod) -{ return ScaledProduct(prod.derived(), x); } - -template -typename internal::enable_if::value, - const ScaledProduct >::type -operator*(const typename Derived::RealScalar& x,const ProductBase& prod) -{ return ScaledProduct(prod.derived(), x); } - -namespace internal { -template -struct traits > - : traits, - typename NestedProduct::_LhsNested, - typename NestedProduct::_RhsNested> > -{ - typedef typename traits::StorageKind StorageKind; -}; -} - -template -class ScaledProduct - : public ProductBase, - typename NestedProduct::_LhsNested, - typename NestedProduct::_RhsNested> -{ - public: - typedef ProductBase, - typename NestedProduct::_LhsNested, - typename NestedProduct::_RhsNested> Base; - typedef typename Base::Scalar Scalar; - typedef typename Base::PlainObject PlainObject; -// IMP_EIGEN_PRODUCT_PUBLIC_INTERFACE(ScaledProduct) - - ScaledProduct(const NestedProduct& prod, const Scalar& x) - : Base(prod.lhs(),prod.rhs()), m_prod(prod), m_alpha(x) {} - - template - inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst, Scalar(1)); } - - template - inline void addTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(1)); } - - template - inline void subTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(-1)); } - - template - inline void scaleAndAddTo(Dest& dst, const Scalar& a_alpha) const { m_prod.derived().scaleAndAddTo(dst,a_alpha * m_alpha); } - - const Scalar& alpha() const { return m_alpha; } - - protected: - const NestedProduct& m_prod; - Scalar m_alpha; -}; - -/** \internal - * Overloaded to perform an efficient C = (A*B).lazy() */ -template -template -Derived& MatrixBase::lazyAssign(const ProductBase& other) -{ - other.derived().evalTo(derived()); - return derived(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_PRODUCTBASE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Random.h b/modules/algebra/include/eigen3/Eigen/src/Core/Random.h deleted file mode 100644 index b393550665..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Random.h +++ /dev/null @@ -1,152 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_RANDOM_H -#define IMP_EIGEN_RANDOM_H - -namespace IMP_Eigen { - -namespace internal { - -template struct scalar_random_op { - IMP_EIGEN_EMPTY_STRUCT_CTOR(scalar_random_op) - template - inline const Scalar operator() (Index, Index = 0) const { return random(); } -}; - -template -struct functor_traits > -{ enum { Cost = 5 * NumTraits::MulCost, PacketAccess = false, IsRepeatable = false }; }; - -} // end namespace internal - -/** \returns a random matrix expression - * - * The parameters \a rows and \a cols are the number of rows and of columns of - * the returned matrix. Must be compatible with this MatrixBase type. - * - * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so Random() should be used - * instead. - * - * Example: \include MatrixBase_random_int_int.cpp - * Output: \verbinclude MatrixBase_random_int_int.out - * - * This expression has the "evaluate before nesting" flag so that it will be evaluated into - * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected - * behavior with expressions involving random matrices. - * - * \sa MatrixBase::setRandom(), MatrixBase::Random(Index), MatrixBase::Random() - */ -template -inline const CwiseNullaryOp::Scalar>, Derived> -DenseBase::Random(Index rows, Index cols) -{ - return NullaryExpr(rows, cols, internal::scalar_random_op()); -} - -/** \returns a random vector expression - * - * The parameter \a size is the size of the returned vector. - * Must be compatible with this MatrixBase type. - * - * \only_for_vectors - * - * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so Random() should be used - * instead. - * - * Example: \include MatrixBase_random_int.cpp - * Output: \verbinclude MatrixBase_random_int.out - * - * This expression has the "evaluate before nesting" flag so that it will be evaluated into - * a temporary vector whenever it is nested in a larger expression. This prevents unexpected - * behavior with expressions involving random matrices. - * - * \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random() - */ -template -inline const CwiseNullaryOp::Scalar>, Derived> -DenseBase::Random(Index size) -{ - return NullaryExpr(size, internal::scalar_random_op()); -} - -/** \returns a fixed-size random matrix or vector expression - * - * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you - * need to use the variants taking size arguments. - * - * Example: \include MatrixBase_random.cpp - * Output: \verbinclude MatrixBase_random.out - * - * This expression has the "evaluate before nesting" flag so that it will be evaluated into - * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected - * behavior with expressions involving random matrices. - * - * \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random(Index) - */ -template -inline const CwiseNullaryOp::Scalar>, Derived> -DenseBase::Random() -{ - return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op()); -} - -/** Sets all coefficients in this expression to random values. - * - * Example: \include MatrixBase_setRandom.cpp - * Output: \verbinclude MatrixBase_setRandom.out - * - * \sa class CwiseNullaryOp, setRandom(Index), setRandom(Index,Index) - */ -template -inline Derived& DenseBase::setRandom() -{ - return *this = Random(rows(), cols()); -} - -/** Resizes to the given \a newSize, and sets all coefficients in this expression to random values. - * - * \only_for_vectors - * - * Example: \include Matrix_setRandom_int.cpp - * Output: \verbinclude Matrix_setRandom_int.out - * - * \sa MatrixBase::setRandom(), setRandom(Index,Index), class CwiseNullaryOp, MatrixBase::Random() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setRandom(Index newSize) -{ - resize(newSize); - return setRandom(); -} - -/** Resizes to the given size, and sets all coefficients in this expression to random values. - * - * \param nbRows the new number of rows - * \param nbCols the new number of columns - * - * Example: \include Matrix_setRandom_int_int.cpp - * Output: \verbinclude Matrix_setRandom_int_int.out - * - * \sa MatrixBase::setRandom(), setRandom(Index), class CwiseNullaryOp, MatrixBase::Random() - */ -template -IMP_EIGEN_STRONG_INLINE Derived& -PlainObjectBase::setRandom(Index nbRows, Index nbCols) -{ - resize(nbRows, nbCols); - return setRandom(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_RANDOM_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Redux.h b/modules/algebra/include/eigen3/Eigen/src/Core/Redux.h deleted file mode 100644 index 7b8d2cfcaf..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Redux.h +++ /dev/null @@ -1,409 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008 Gael Guennebaud -// Copyright (C) 2006-2008 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_REDUX_H -#define IMP_EIGEN_REDUX_H - -namespace IMP_Eigen { - -namespace internal { - -// TODO -// * implement other kind of vectorization -// * factorize code - -/*************************************************************************** -* Part 1 : the logic deciding a strategy for vectorization and unrolling -***************************************************************************/ - -template -struct redux_traits -{ -public: - enum { - PacketSize = packet_traits::size, - InnerMaxSize = int(Derived::IsRowMajor) - ? Derived::MaxColsAtCompileTime - : Derived::MaxRowsAtCompileTime - }; - - enum { - MightVectorize = (int(Derived::Flags)&ActualPacketAccessBit) - && (functor_traits::PacketAccess), - MayLinearVectorize = MightVectorize && (int(Derived::Flags)&LinearAccessBit), - MaySliceVectorize = MightVectorize && int(InnerMaxSize)>=3*PacketSize - }; - -public: - enum { - Traversal = int(MayLinearVectorize) ? int(LinearVectorizedTraversal) - : int(MaySliceVectorize) ? int(SliceVectorizedTraversal) - : int(DefaultTraversal) - }; - -public: - enum { - Cost = ( Derived::SizeAtCompileTime == Dynamic - || Derived::CoeffReadCost == Dynamic - || (Derived::SizeAtCompileTime!=1 && functor_traits::Cost == Dynamic) - ) ? Dynamic - : Derived::SizeAtCompileTime * Derived::CoeffReadCost - + (Derived::SizeAtCompileTime-1) * functor_traits::Cost, - UnrollingLimit = IMP_EIGEN_UNROLLING_LIMIT * (int(Traversal) == int(DefaultTraversal) ? 1 : int(PacketSize)) - }; - -public: - enum { - Unrolling = Cost != Dynamic && Cost <= UnrollingLimit - ? CompleteUnrolling - : NoUnrolling - }; -}; - -/*************************************************************************** -* Part 2 : unrollers -***************************************************************************/ - -/*** no vectorization ***/ - -template -struct redux_novec_unroller -{ - enum { - HalfLength = Length/2 - }; - - typedef typename Derived::Scalar Scalar; - - static IMP_EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func& func) - { - return func(redux_novec_unroller::run(mat,func), - redux_novec_unroller::run(mat,func)); - } -}; - -template -struct redux_novec_unroller -{ - enum { - outer = Start / Derived::InnerSizeAtCompileTime, - inner = Start % Derived::InnerSizeAtCompileTime - }; - - typedef typename Derived::Scalar Scalar; - - static IMP_EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func&) - { - return mat.coeffByOuterInner(outer, inner); - } -}; - -// This is actually dead code and will never be called. It is required -// to prevent false warnings regarding failed inlining though -// for 0 length run() will never be called at all. -template -struct redux_novec_unroller -{ - typedef typename Derived::Scalar Scalar; - static IMP_EIGEN_STRONG_INLINE Scalar run(const Derived&, const Func&) { return Scalar(); } -}; - -/*** vectorization ***/ - -template -struct redux_vec_unroller -{ - enum { - PacketSize = packet_traits::size, - HalfLength = Length/2 - }; - - typedef typename Derived::Scalar Scalar; - typedef typename packet_traits::type PacketScalar; - - static IMP_EIGEN_STRONG_INLINE PacketScalar run(const Derived &mat, const Func& func) - { - return func.packetOp( - redux_vec_unroller::run(mat,func), - redux_vec_unroller::run(mat,func) ); - } -}; - -template -struct redux_vec_unroller -{ - enum { - index = Start * packet_traits::size, - outer = index / int(Derived::InnerSizeAtCompileTime), - inner = index % int(Derived::InnerSizeAtCompileTime), - alignment = (Derived::Flags & AlignedBit) ? Aligned : Unaligned - }; - - typedef typename Derived::Scalar Scalar; - typedef typename packet_traits::type PacketScalar; - - static IMP_EIGEN_STRONG_INLINE PacketScalar run(const Derived &mat, const Func&) - { - return mat.template packetByOuterInner(outer, inner); - } -}; - -/*************************************************************************** -* Part 3 : implementation of all cases -***************************************************************************/ - -template::Traversal, - int Unrolling = redux_traits::Unrolling -> -struct redux_impl; - -template -struct redux_impl -{ - typedef typename Derived::Scalar Scalar; - typedef typename Derived::Index Index; - static IMP_EIGEN_STRONG_INLINE Scalar run(const Derived& mat, const Func& func) - { - imp_eigen_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); - Scalar res; - res = mat.coeffByOuterInner(0, 0); - for(Index i = 1; i < mat.innerSize(); ++i) - res = func(res, mat.coeffByOuterInner(0, i)); - for(Index i = 1; i < mat.outerSize(); ++i) - for(Index j = 0; j < mat.innerSize(); ++j) - res = func(res, mat.coeffByOuterInner(i, j)); - return res; - } -}; - -template -struct redux_impl - : public redux_novec_unroller -{}; - -template -struct redux_impl -{ - typedef typename Derived::Scalar Scalar; - typedef typename packet_traits::type PacketScalar; - typedef typename Derived::Index Index; - - static Scalar run(const Derived& mat, const Func& func) - { - const Index size = mat.size(); - imp_eigen_assert(size && "you are using an empty matrix"); - const Index packetSize = packet_traits::size; - const Index alignedStart = internal::first_aligned(mat); - enum { - alignment = bool(Derived::Flags & DirectAccessBit) || bool(Derived::Flags & AlignedBit) - ? Aligned : Unaligned - }; - const Index alignedSize2 = ((size-alignedStart)/(2*packetSize))*(2*packetSize); - const Index alignedSize = ((size-alignedStart)/(packetSize))*(packetSize); - const Index alignedEnd2 = alignedStart + alignedSize2; - const Index alignedEnd = alignedStart + alignedSize; - Scalar res; - if(alignedSize) - { - PacketScalar packet_res0 = mat.template packet(alignedStart); - if(alignedSize>packetSize) // we have at least two packets to partly unroll the loop - { - PacketScalar packet_res1 = mat.template packet(alignedStart+packetSize); - for(Index index = alignedStart + 2*packetSize; index < alignedEnd2; index += 2*packetSize) - { - packet_res0 = func.packetOp(packet_res0, mat.template packet(index)); - packet_res1 = func.packetOp(packet_res1, mat.template packet(index+packetSize)); - } - - packet_res0 = func.packetOp(packet_res0,packet_res1); - if(alignedEnd>alignedEnd2) - packet_res0 = func.packetOp(packet_res0, mat.template packet(alignedEnd2)); - } - res = func.predux(packet_res0); - - for(Index index = 0; index < alignedStart; ++index) - res = func(res,mat.coeff(index)); - - for(Index index = alignedEnd; index < size; ++index) - res = func(res,mat.coeff(index)); - } - else // too small to vectorize anything. - // since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize. - { - res = mat.coeff(0); - for(Index index = 1; index < size; ++index) - res = func(res,mat.coeff(index)); - } - - return res; - } -}; - -// NOTE: for SliceVectorizedTraversal we simply bypass unrolling -template -struct redux_impl -{ - typedef typename Derived::Scalar Scalar; - typedef typename packet_traits::type PacketScalar; - typedef typename Derived::Index Index; - - static Scalar run(const Derived& mat, const Func& func) - { - imp_eigen_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); - const Index innerSize = mat.innerSize(); - const Index outerSize = mat.outerSize(); - enum { - packetSize = packet_traits::size - }; - const Index packetedInnerSize = ((innerSize)/packetSize)*packetSize; - Scalar res; - if(packetedInnerSize) - { - PacketScalar packet_res = mat.template packet(0,0); - for(Index j=0; j(j,i)); - - res = func.predux(packet_res); - for(Index j=0; j::run(mat, func); - } - - return res; - } -}; - -template -struct redux_impl -{ - typedef typename Derived::Scalar Scalar; - typedef typename packet_traits::type PacketScalar; - enum { - PacketSize = packet_traits::size, - Size = Derived::SizeAtCompileTime, - VectorizedSize = (Size / PacketSize) * PacketSize - }; - static IMP_EIGEN_STRONG_INLINE Scalar run(const Derived& mat, const Func& func) - { - imp_eigen_assert(mat.rows()>0 && mat.cols()>0 && "you are using an empty matrix"); - Scalar res = func.predux(redux_vec_unroller::run(mat,func)); - if (VectorizedSize != Size) - res = func(res,redux_novec_unroller::run(mat,func)); - return res; - } -}; - -} // end namespace internal - -/*************************************************************************** -* Part 4 : public API -***************************************************************************/ - - -/** \returns the result of a full redux operation on the whole matrix or vector using \a func - * - * The template parameter \a BinaryOp is the type of the functor \a func which must be - * an associative operator. Both current STL and TR1 functor styles are handled. - * - * \sa DenseBase::sum(), DenseBase::minCoeff(), DenseBase::maxCoeff(), MatrixBase::colwise(), MatrixBase::rowwise() - */ -template -template -IMP_EIGEN_STRONG_INLINE typename internal::result_of::Scalar)>::type -DenseBase::redux(const Func& func) const -{ - typedef typename internal::remove_all::type ThisNested; - return internal::redux_impl - ::run(derived(), func); -} - -/** \returns the minimum of all coefficients of \c *this. - * \warning the result is undefined if \c *this contains NaN. - */ -template -IMP_EIGEN_STRONG_INLINE typename internal::traits::Scalar -DenseBase::minCoeff() const -{ - return this->redux(IMP_Eigen::internal::scalar_min_op()); -} - -/** \returns the maximum of all coefficients of \c *this. - * \warning the result is undefined if \c *this contains NaN. - */ -template -IMP_EIGEN_STRONG_INLINE typename internal::traits::Scalar -DenseBase::maxCoeff() const -{ - return this->redux(IMP_Eigen::internal::scalar_max_op()); -} - -/** \returns the sum of all coefficients of *this - * - * \sa trace(), prod(), mean() - */ -template -IMP_EIGEN_STRONG_INLINE typename internal::traits::Scalar -DenseBase::sum() const -{ - if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0)) - return Scalar(0); - return this->redux(IMP_Eigen::internal::scalar_sum_op()); -} - -/** \returns the mean of all coefficients of *this -* -* \sa trace(), prod(), sum() -*/ -template -IMP_EIGEN_STRONG_INLINE typename internal::traits::Scalar -DenseBase::mean() const -{ - return Scalar(this->redux(IMP_Eigen::internal::scalar_sum_op())) / Scalar(this->size()); -} - -/** \returns the product of all coefficients of *this - * - * Example: \include MatrixBase_prod.cpp - * Output: \verbinclude MatrixBase_prod.out - * - * \sa sum(), mean(), trace() - */ -template -IMP_EIGEN_STRONG_INLINE typename internal::traits::Scalar -DenseBase::prod() const -{ - if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0)) - return Scalar(1); - return this->redux(IMP_Eigen::internal::scalar_product_op()); -} - -/** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal. - * - * \c *this can be any matrix, not necessarily square. - * - * \sa diagonal(), sum() - */ -template -IMP_EIGEN_STRONG_INLINE typename internal::traits::Scalar -MatrixBase::trace() const -{ - return derived().diagonal().sum(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_REDUX_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Ref.h b/modules/algebra/include/eigen3/Eigen/src/Core/Ref.h deleted file mode 100644 index ed2b8ba76d..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Ref.h +++ /dev/null @@ -1,278 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_REF_H -#define IMP_EIGEN_REF_H - -namespace IMP_Eigen { - -template class RefBase; -template,OuterStride<> >::type > class Ref; - -/** \class Ref - * \ingroup Core_Module - * - * \brief A matrix or vector expression mapping an existing expressions - * - * \tparam PlainObjectType the equivalent matrix type of the mapped data - * \tparam Options specifies whether the pointer is \c #Aligned, or \c #Unaligned. - * The default is \c #Unaligned. - * \tparam StrideType optionally specifies strides. By default, Ref implies a contiguous storage along the inner dimension (inner stride==1), - * but accept a variable outer stride (leading dimension). - * This can be overridden by specifying strides. - * The type passed here must be a specialization of the Stride template, see examples below. - * - * This class permits to write non template functions taking Eigen's object as parameters while limiting the number of copies. - * A Ref<> object can represent either a const expression or a l-value: - * \code - * // in-out argument: - * void foo1(Ref x); - * - * // read-only const argument: - * void foo2(const Ref& x); - * \endcode - * - * In the in-out case, the input argument must satisfies the constraints of the actual Ref<> type, otherwise a compilation issue will be triggered. - * By default, a Ref can reference any dense vector expression of float having a contiguous memory layout. - * Likewise, a Ref can reference any column major dense matrix expression of float whose column's elements are contiguously stored with - * the possibility to have a constant space inbetween each column, i.e.: the inner stride mmust be equal to 1, but the outer-stride (or leading dimension), - * can be greater than the number of rows. - * - * In the const case, if the input expression does not match the above requirement, then it is evaluated into a temporary before being passed to the function. - * Here are some examples: - * \code - * MatrixXf A; - * VectorXf a; - * foo1(a.head()); // OK - * foo1(A.col()); // OK - * foo1(A.row()); // compilation error because here innerstride!=1 - * foo2(A.row()); // The row is copied into a contiguous temporary - * foo2(2*a); // The expression is evaluated into a temporary - * foo2(A.col().segment(2,4)); // No temporary - * \endcode - * - * The range of inputs that can be referenced without temporary can be enlarged using the last two template parameter. - * Here is an example accepting an innerstride!=1: - * \code - * // in-out argument: - * void foo3(Ref > x); - * foo3(A.row()); // OK - * \endcode - * The downside here is that the function foo3 might be significantly slower than foo1 because it won't be able to exploit vectorization, and will involved more - * expensive address computations even if the input is contiguously stored in memory. To overcome this issue, one might propose to overloads internally calling a - * template function, e.g.: - * \code - * // in the .h: - * void foo(const Ref& A); - * void foo(const Ref >& A); - * - * // in the .cpp: - * template void foo_impl(const TypeOfA& A) { - * ... // crazy code goes here - * } - * void foo(const Ref& A) { foo_impl(A); } - * void foo(const Ref >& A) { foo_impl(A); } - * \endcode - * - * - * \sa PlainObjectBase::Map(), \ref TopicStorageOrders - */ - -namespace internal { - -template -struct traits > - : public traits > -{ - typedef _PlainObjectType PlainObjectType; - typedef _StrideType StrideType; - enum { - Options = _Options, - Flags = traits >::Flags | NestByRefBit - }; - - template struct match { - enum { - HasDirectAccess = internal::has_direct_access::ret, - StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)), - InnerStrideMatch = int(StrideType::InnerStrideAtCompileTime)==int(Dynamic) - || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime) - || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1), - OuterStrideMatch = Derived::IsVectorAtCompileTime - || int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime), - AlignmentMatch = (_Options!=Aligned) || ((PlainObjectType::Flags&AlignedBit)==0) || ((traits::Flags&AlignedBit)==AlignedBit), - ScalarTypeMatch = internal::is_same::value, - MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch && ScalarTypeMatch - }; - typedef typename internal::conditional::type type; - }; - -}; - -template -struct traits > : public traits {}; - -} - -template class RefBase - : public MapBase -{ - typedef typename internal::traits::PlainObjectType PlainObjectType; - typedef typename internal::traits::StrideType StrideType; - -public: - - typedef MapBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(RefBase) - - inline Index innerStride() const - { - return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1; - } - - inline Index outerStride() const - { - return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer() - : IsVectorAtCompileTime ? this->size() - : int(Flags)&RowMajorBit ? this->cols() - : this->rows(); - } - - RefBase() - : Base(0,RowsAtCompileTime==Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==Dynamic?0:ColsAtCompileTime), - // Stride<> does not allow default ctor for Dynamic strides, so let' initialize it with dummy values: - m_stride(StrideType::OuterStrideAtCompileTime==Dynamic?0:StrideType::OuterStrideAtCompileTime, - StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime) - {} - - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(RefBase) - -protected: - - typedef Stride StrideBase; - - template - void construct(Expression& expr) - { - if(PlainObjectType::RowsAtCompileTime==1) - { - imp_eigen_assert(expr.rows()==1 || expr.cols()==1); - ::new (static_cast(this)) Base(expr.data(), 1, expr.size()); - } - else if(PlainObjectType::ColsAtCompileTime==1) - { - imp_eigen_assert(expr.rows()==1 || expr.cols()==1); - ::new (static_cast(this)) Base(expr.data(), expr.size(), 1); - } - else - ::new (static_cast(this)) Base(expr.data(), expr.rows(), expr.cols()); - - if(Expression::IsVectorAtCompileTime && (!PlainObjectType::IsVectorAtCompileTime) && ((Expression::Flags&RowMajorBit)!=(PlainObjectType::Flags&RowMajorBit))) - ::new (&m_stride) StrideBase(expr.innerStride(), StrideType::InnerStrideAtCompileTime==0?0:1); - else - ::new (&m_stride) StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(), - StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride()); - } - - StrideBase m_stride; -}; - - -template class Ref - : public RefBase > -{ - private: - typedef internal::traits Traits; - template - inline Ref(const PlainObjectBase& expr, - typename internal::enable_if::MatchAtCompileTime),Derived>::type* = 0); - public: - - typedef RefBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Ref) - - - #ifndef IMP_EIGEN_PARSED_BY_DOXYGEN - template - inline Ref(PlainObjectBase& expr, - typename internal::enable_if::MatchAtCompileTime),Derived>::type* = 0) - { - IMP_EIGEN_STATIC_ASSERT(static_cast(Traits::template match::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH); - Base::construct(expr.derived()); - } - template - inline Ref(const DenseBase& expr, - typename internal::enable_if::MatchAtCompileTime),Derived>::type* = 0) - #else - template - inline Ref(DenseBase& expr) - #endif - { - IMP_EIGEN_STATIC_ASSERT(static_cast(internal::is_lvalue::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY); - IMP_EIGEN_STATIC_ASSERT(static_cast(Traits::template match::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH); - enum { THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY = Derived::ThisConstantIsPrivateInPlainObjectBase}; - Base::construct(expr.const_cast_derived()); - } - - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Ref) - -}; - -// this is the const ref version -template class Ref - : public RefBase > -{ - typedef internal::traits Traits; - public: - - typedef RefBase Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Ref) - - template - inline Ref(const DenseBase& expr, - typename internal::enable_if::ScalarTypeMatch),Derived>::type* = 0) - { -// std::cout << match_helper::HasDirectAccess << "," << match_helper::OuterStrideMatch << "," << match_helper::InnerStrideMatch << "\n"; -// std::cout << int(StrideType::OuterStrideAtCompileTime) << " - " << int(Derived::OuterStrideAtCompileTime) << "\n"; -// std::cout << int(StrideType::InnerStrideAtCompileTime) << " - " << int(Derived::InnerStrideAtCompileTime) << "\n"; - construct(expr.derived(), typename Traits::template match::type()); - } - - inline Ref(const Ref& other) : Base(other) { - // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy - } - - template - inline Ref(const RefBase& other) { - construct(other.derived(), typename Traits::template match::type()); - } - - protected: - - template - void construct(const Expression& expr,internal::true_type) - { - Base::construct(expr); - } - - template - void construct(const Expression& expr, internal::false_type) - { - m_object.lazyAssign(expr); - Base::construct(m_object); - } - - protected: - TPlainObjectType m_object; -}; - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_REF_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Replicate.h b/modules/algebra/include/eigen3/Eigen/src/Core/Replicate.h deleted file mode 100644 index 581f6aee16..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Replicate.h +++ /dev/null @@ -1,177 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_REPLICATE_H -#define IMP_EIGEN_REPLICATE_H - -namespace IMP_Eigen { - -/** - * \class Replicate - * \ingroup Core_Module - * - * \brief Expression of the multiple replication of a matrix or vector - * - * \param MatrixType the type of the object we are replicating - * - * This class represents an expression of the multiple replication of a matrix or vector. - * It is the return type of DenseBase::replicate() and most of the time - * this is the only way it is used. - * - * \sa DenseBase::replicate() - */ - -namespace internal { -template -struct traits > - : traits -{ - typedef typename MatrixType::Scalar Scalar; - typedef typename traits::StorageKind StorageKind; - typedef typename traits::XprKind XprKind; - enum { - Factor = (RowFactor==Dynamic || ColFactor==Dynamic) ? Dynamic : RowFactor*ColFactor - }; - typedef typename nested::type MatrixTypeNested; - typedef typename remove_reference::type _MatrixTypeNested; - enum { - RowsAtCompileTime = RowFactor==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic - ? Dynamic - : RowFactor * MatrixType::RowsAtCompileTime, - ColsAtCompileTime = ColFactor==Dynamic || int(MatrixType::ColsAtCompileTime)==Dynamic - ? Dynamic - : ColFactor * MatrixType::ColsAtCompileTime, - //FIXME we don't propagate the max sizes !!! - MaxRowsAtCompileTime = RowsAtCompileTime, - MaxColsAtCompileTime = ColsAtCompileTime, - IsRowMajor = MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1 ? 1 - : MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1 ? 0 - : (MatrixType::Flags & RowMajorBit) ? 1 : 0, - Flags = (_MatrixTypeNested::Flags & HereditaryBits & ~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0), - CoeffReadCost = _MatrixTypeNested::CoeffReadCost - }; -}; -} - -template class Replicate - : public internal::dense_xpr_base< Replicate >::type -{ - typedef typename internal::traits::MatrixTypeNested MatrixTypeNested; - typedef typename internal::traits::_MatrixTypeNested _MatrixTypeNested; - public: - - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Replicate) - - template - inline explicit Replicate(const OriginalMatrixType& a_matrix) - : m_matrix(a_matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor) - { - IMP_EIGEN_STATIC_ASSERT((internal::is_same::type,OriginalMatrixType>::value), - THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE) - imp_eigen_assert(RowFactor!=Dynamic && ColFactor!=Dynamic); - } - - template - inline Replicate(const OriginalMatrixType& a_matrix, Index rowFactor, Index colFactor) - : m_matrix(a_matrix), m_rowFactor(rowFactor), m_colFactor(colFactor) - { - IMP_EIGEN_STATIC_ASSERT((internal::is_same::type,OriginalMatrixType>::value), - THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE) - } - - inline Index rows() const { return m_matrix.rows() * m_rowFactor.value(); } - inline Index cols() const { return m_matrix.cols() * m_colFactor.value(); } - - inline Scalar coeff(Index rowId, Index colId) const - { - // try to avoid using modulo; this is a pure optimization strategy - const Index actual_row = internal::traits::RowsAtCompileTime==1 ? 0 - : RowFactor==1 ? rowId - : rowId%m_matrix.rows(); - const Index actual_col = internal::traits::ColsAtCompileTime==1 ? 0 - : ColFactor==1 ? colId - : colId%m_matrix.cols(); - - return m_matrix.coeff(actual_row, actual_col); - } - template - inline PacketScalar packet(Index rowId, Index colId) const - { - const Index actual_row = internal::traits::RowsAtCompileTime==1 ? 0 - : RowFactor==1 ? rowId - : rowId%m_matrix.rows(); - const Index actual_col = internal::traits::ColsAtCompileTime==1 ? 0 - : ColFactor==1 ? colId - : colId%m_matrix.cols(); - - return m_matrix.template packet(actual_row, actual_col); - } - - const _MatrixTypeNested& nestedExpression() const - { - return m_matrix; - } - - protected: - MatrixTypeNested m_matrix; - const internal::variable_if_dynamic m_rowFactor; - const internal::variable_if_dynamic m_colFactor; -}; - -/** - * \return an expression of the replication of \c *this - * - * Example: \include MatrixBase_replicate.cpp - * Output: \verbinclude MatrixBase_replicate.out - * - * \sa VectorwiseOp::replicate(), DenseBase::replicate(Index,Index), class Replicate - */ -template -template -const Replicate -DenseBase::replicate() const -{ - return Replicate(derived()); -} - -/** - * \return an expression of the replication of \c *this - * - * Example: \include MatrixBase_replicate_int_int.cpp - * Output: \verbinclude MatrixBase_replicate_int_int.out - * - * \sa VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate - */ -template -const typename DenseBase::ReplicateReturnType -DenseBase::replicate(Index rowFactor,Index colFactor) const -{ - return Replicate(derived(),rowFactor,colFactor); -} - -/** - * \return an expression of the replication of each column (or row) of \c *this - * - * Example: \include DirectionWise_replicate_int.cpp - * Output: \verbinclude DirectionWise_replicate_int.out - * - * \sa VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate - */ -template -const typename VectorwiseOp::ReplicateReturnType -VectorwiseOp::replicate(Index factor) const -{ - return typename VectorwiseOp::ReplicateReturnType - (_expression(),Direction==Vertical?factor:1,Direction==Horizontal?factor:1); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_REPLICATE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/ReturnByValue.h b/modules/algebra/include/eigen3/Eigen/src/Core/ReturnByValue.h deleted file mode 100644 index 30cdd1365c..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/ReturnByValue.h +++ /dev/null @@ -1,99 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009-2010 Gael Guennebaud -// Copyright (C) 2009-2010 Benoit Jacob -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_RETURNBYVALUE_H -#define IMP_EIGEN_RETURNBYVALUE_H - -namespace IMP_Eigen { - -/** \class ReturnByValue - * \ingroup Core_Module - * - */ - -namespace internal { - -template -struct traits > - : public traits::ReturnType> -{ - enum { - // We're disabling the DirectAccess because e.g. the constructor of - // the Block-with-DirectAccess expression requires to have a coeffRef method. - // Also, we don't want to have to implement the stride stuff. - Flags = (traits::ReturnType>::Flags - | EvalBeforeNestingBit) & ~DirectAccessBit - }; -}; - -/* The ReturnByValue object doesn't even have a coeff() method. - * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix. - * So internal::nested always gives the plain return matrix type. - * - * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ?? - */ -template -struct nested, n, PlainObject> -{ - typedef typename traits::ReturnType type; -}; - -} // end namespace internal - -template class ReturnByValue - : internal::no_assignment_operator, public internal::dense_xpr_base< ReturnByValue >::type -{ - public: - typedef typename internal::traits::ReturnType ReturnType; - - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) - - template - inline void evalTo(Dest& dst) const - { static_cast(this)->evalTo(dst); } - inline Index rows() const { return static_cast(this)->rows(); } - inline Index cols() const { return static_cast(this)->cols(); } - -#ifndef IMP_EIGEN_PARSED_BY_DOXYGEN -#define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT - class Unusable{ - Unusable(const Unusable&) {} - Unusable& operator=(const Unusable&) {return *this;} - }; - const Unusable& coeff(Index) const { return *reinterpret_cast(this); } - const Unusable& coeff(Index,Index) const { return *reinterpret_cast(this); } - Unusable& coeffRef(Index) { return *reinterpret_cast(this); } - Unusable& coeffRef(Index,Index) { return *reinterpret_cast(this); } - template Unusable& packet(Index) const; - template Unusable& packet(Index, Index) const; -#endif -}; - -template -template -Derived& DenseBase::operator=(const ReturnByValue& other) -{ - other.evalTo(derived()); - return derived(); -} - -template -template -Derived& DenseBase::lazyAssign(const ReturnByValue& other) -{ - other.evalTo(derived()); - return derived(); -} - - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_RETURNBYVALUE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Reverse.h b/modules/algebra/include/eigen3/Eigen/src/Core/Reverse.h deleted file mode 100644 index 4d284bbfd0..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Reverse.h +++ /dev/null @@ -1,224 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2008 Benoit Jacob -// Copyright (C) 2009 Ricard Marxer -// Copyright (C) 2009-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_REVERSE_H -#define IMP_EIGEN_REVERSE_H - -namespace IMP_Eigen { - -/** \class Reverse - * \ingroup Core_Module - * - * \brief Expression of the reverse of a vector or matrix - * - * \param MatrixType the type of the object of which we are taking the reverse - * - * This class represents an expression of the reverse of a vector. - * It is the return type of MatrixBase::reverse() and VectorwiseOp::reverse() - * and most of the time this is the only way it is used. - * - * \sa MatrixBase::reverse(), VectorwiseOp::reverse() - */ - -namespace internal { - -template -struct traits > - : traits -{ - typedef typename MatrixType::Scalar Scalar; - typedef typename traits::StorageKind StorageKind; - typedef typename traits::XprKind XprKind; - typedef typename nested::type MatrixTypeNested; - typedef typename remove_reference::type _MatrixTypeNested; - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - - // let's enable LinearAccess only with vectorization because of the product overhead - LinearAccess = ( (Direction==BothDirections) && (int(_MatrixTypeNested::Flags)&PacketAccessBit) ) - ? LinearAccessBit : 0, - - Flags = int(_MatrixTypeNested::Flags) & (HereditaryBits | LvalueBit | PacketAccessBit | LinearAccess), - - CoeffReadCost = _MatrixTypeNested::CoeffReadCost - }; -}; - -template struct reverse_packet_cond -{ - static inline PacketScalar run(const PacketScalar& x) { return preverse(x); } -}; - -template struct reverse_packet_cond -{ - static inline PacketScalar run(const PacketScalar& x) { return x; } -}; - -} // end namespace internal - -template class Reverse - : public internal::dense_xpr_base< Reverse >::type -{ - public: - - typedef typename internal::dense_xpr_base::type Base; - IMP_EIGEN_DENSE_PUBLIC_INTERFACE(Reverse) - using Base::IsRowMajor; - - // next line is necessary because otherwise const version of operator() - // is hidden by non-const version defined in this file - using Base::operator(); - - protected: - enum { - PacketSize = internal::packet_traits::size, - IsColMajor = !IsRowMajor, - ReverseRow = (Direction == Vertical) || (Direction == BothDirections), - ReverseCol = (Direction == Horizontal) || (Direction == BothDirections), - OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1, - OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1, - ReversePacket = (Direction == BothDirections) - || ((Direction == Vertical) && IsColMajor) - || ((Direction == Horizontal) && IsRowMajor) - }; - typedef internal::reverse_packet_cond reverse_packet; - public: - - inline Reverse(const MatrixType& matrix) : m_matrix(matrix) { } - - IMP_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Reverse) - - inline Index rows() const { return m_matrix.rows(); } - inline Index cols() const { return m_matrix.cols(); } - - inline Index innerStride() const - { - return -m_matrix.innerStride(); - } - - inline Scalar& operator()(Index row, Index col) - { - imp_eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); - return coeffRef(row, col); - } - - inline Scalar& coeffRef(Index row, Index col) - { - return m_matrix.const_cast_derived().coeffRef(ReverseRow ? m_matrix.rows() - row - 1 : row, - ReverseCol ? m_matrix.cols() - col - 1 : col); - } - - inline CoeffReturnType coeff(Index row, Index col) const - { - return m_matrix.coeff(ReverseRow ? m_matrix.rows() - row - 1 : row, - ReverseCol ? m_matrix.cols() - col - 1 : col); - } - - inline CoeffReturnType coeff(Index index) const - { - return m_matrix.coeff(m_matrix.size() - index - 1); - } - - inline Scalar& coeffRef(Index index) - { - return m_matrix.const_cast_derived().coeffRef(m_matrix.size() - index - 1); - } - - inline Scalar& operator()(Index index) - { - imp_eigen_assert(index >= 0 && index < m_matrix.size()); - return coeffRef(index); - } - - template - inline const PacketScalar packet(Index row, Index col) const - { - return reverse_packet::run(m_matrix.template packet( - ReverseRow ? m_matrix.rows() - row - OffsetRow : row, - ReverseCol ? m_matrix.cols() - col - OffsetCol : col)); - } - - template - inline void writePacket(Index row, Index col, const PacketScalar& x) - { - m_matrix.const_cast_derived().template writePacket( - ReverseRow ? m_matrix.rows() - row - OffsetRow : row, - ReverseCol ? m_matrix.cols() - col - OffsetCol : col, - reverse_packet::run(x)); - } - - template - inline const PacketScalar packet(Index index) const - { - return internal::preverse(m_matrix.template packet( m_matrix.size() - index - PacketSize )); - } - - template - inline void writePacket(Index index, const PacketScalar& x) - { - m_matrix.const_cast_derived().template writePacket(m_matrix.size() - index - PacketSize, internal::preverse(x)); - } - - const typename internal::remove_all::type& - nestedExpression() const - { - return m_matrix; - } - - protected: - typename MatrixType::Nested m_matrix; -}; - -/** \returns an expression of the reverse of *this. - * - * Example: \include MatrixBase_reverse.cpp - * Output: \verbinclude MatrixBase_reverse.out - * - */ -template -inline typename DenseBase::ReverseReturnType -DenseBase::reverse() -{ - return derived(); -} - -/** This is the const version of reverse(). */ -template -inline const typename DenseBase::ConstReverseReturnType -DenseBase::reverse() const -{ - return derived(); -} - -/** This is the "in place" version of reverse: it reverses \c *this. - * - * In most cases it is probably better to simply use the reversed expression - * of a matrix. However, when reversing the matrix data itself is really needed, - * then this "in-place" version is probably the right choice because it provides - * the following additional features: - * - less error prone: doing the same operation with .reverse() requires special care: - * \code m = m.reverse().eval(); \endcode - * - this API allows to avoid creating a temporary (the current implementation creates a temporary, but that could be avoided using swap) - * - it allows future optimizations (cache friendliness, etc.) - * - * \sa reverse() */ -template -inline void DenseBase::reverseInPlace() -{ - derived() = derived().reverse().eval(); -} - -} // end namespace IMP_Eigen - -#endif // IMP_EIGEN_REVERSE_H diff --git a/modules/algebra/include/eigen3/Eigen/src/Core/Select.h b/modules/algebra/include/eigen3/Eigen/src/Core/Select.h deleted file mode 100644 index 97bcedaa68..0000000000 --- a/modules/algebra/include/eigen3/Eigen/src/Core/Select.h +++ /dev/null @@ -1,162 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2008-2010 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef IMP_EIGEN_SELECT_H -#define IMP_EIGEN_SELECT_H - -namespace IMP_Eigen { - -/** \class Select - * \ingroup Core_Module - * - * \brief Expression of a coefficient wise version of the C++ ternary operator ?: - * - * \param ConditionMatrixType the type of the \em condition expression which must be a boolean matrix - * \param ThenMatrixType the type of the \em then expression - * \param ElseMatrixType the type of the \em else expression - * - * This class represents an expression of a coefficient wise version of the C++ ternary operator ?:. - * It is the return type of DenseBase::select() and most of the time this is the only way it is used. - * - * \sa DenseBase::select(const DenseBase&, const DenseBase&) const - */ - -namespace internal { -template -struct traits > - : traits -{ - typedef typename traits::Scalar Scalar; - typedef Dense StorageKind; - typedef typename traits::XprKind XprKind; - typedef typename ConditionMatrixType::Nested ConditionMatrixNested; - typedef typename ThenMatrixType::Nested ThenMatrixNested; - typedef typename ElseMatrixType::Nested ElseMatrixNested; - enum { - RowsAtCompileTime = ConditionMatrixType::RowsAtCompileTime, - ColsAtCompileTime = ConditionMatrixType::ColsAtCompileTime, - MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime, - Flags = (unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & HereditaryBits, - CoeffReadCost = traits::type>::CoeffReadCost - + IMP_EIGEN_SIZE_MAX(traits::type>::CoeffReadCost, - traits::type>::CoeffReadCost) - }; -}; -} - -template -class Select : internal::no_assignment_operator, - public internal::dense_xpr_base< Select >::type -{ - public: - - typedef typename internal::dense_xpr_base