Commit ad95390a authored by Martin Marinov's avatar Martin Marinov
Browse files

Add explicit template instantiation for template functionality as needed....

Add explicit template instantiation for template functionality as needed. Template header files no longer include template definitions (*T.cc) files, disabled with the global define. Added proper .cc files as required that include the corresponding *T.cc file and instantiate the templates.

[git-p4: depot-paths = "//ReForm/ReForm/main/CoMISo/": change = 10343]
parent df6ec112
......@@ -22,7 +22,7 @@ add_library(CoMISo ${SOURCES} ${HEADERS})
if (MSVC)
#add_definitions(-DCOMISODLL) #build static for now
add_definitions(-DINCLUDE_TEMPLATES) # TODO: Get rid of this?!
#add_definitions(-DINCLUDE_TEMPLATES) (disabled, use explicit instantiation instead)
add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
......
set(my_headers
${CMAKE_CURRENT_SOURCE_DIR}/config.hh
${CMAKE_CURRENT_SOURCE_DIR}/CoMISoDefines.hh
${CMAKE_CURRENT_SOURCE_DIR}/GmmTypes.hh
${CMAKE_CURRENT_SOURCE_DIR}/StdTypes.hh
PARENT_SCOPE
)
......
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef GMMTYPES_HH_INCLUDED
#define GMMTYPES_HH_INCLUDED
#include <gmm/gmm.h>
namespace COMISO_GMM
{
// Matrix Types
typedef gmm::col_matrix< gmm::wsvector<double> > WSColMatrix;
typedef gmm::row_matrix< gmm::wsvector<double> > WSRowMatrix;
typedef gmm::col_matrix< gmm::rsvector<double> > RSColMatrix;
typedef gmm::csc_matrix<double> CSCMatrix;
}//namespace COMISO_GMM
#endif//GMMTYPES_HH_INCLUDED
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef STDTYPES_HH_INCLUDED
#define STDTYPES_HH_INCLUDED
#include <vector>
namespace COMISO_STD
{
// Vector Types
typedef std::vector<double> DoubleVector;
typedef std::vector<int> IntVector;
typedef std::vector<unsigned int> UIntVector;
}//namespace COMISO_GMM
#endif//STDTYPES_HH_INCLUDED
// Build time dependencies for CoMiso
@COMISO_QT4_CONFIG_FILE_SETTINGS@
@COMISO_BOOST_CONFIG_FILE_SETTINGS@
@COMISO_BLAS_CONFIG_FILE_SETTINGS@
@COMISO_GMM_CONFIG_FILE_SETTINGS@
@COMISO_ADOLC_CONFIG_FILE_SETTINGS@
@COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS@
@COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS@
@COMISO_MPI_CONFIG_FILE_SETTINGS@
@COMISO_HSL_CONFIG_FILE_SETTINGS@
@COMISO_PETSC_CONFIG_FILE_SETTINGS@
@COMISO_TAO_CONFIG_FILE_SETTINGS@
@COMISO_IPOPT_CONFIG_FILE_SETTINGS@
@COMISO_MUMPS_CONFIG_FILE_SETTINGS@
@COMISO_METIS_CONFIG_FILE_SETTINGS@
@COMISO_CGAL_CONFIG_FILE_SETTINGS@
@COMISO_TAUCS_CONFIG_FILE_SETTINGS@
@COMISO_GUROBI_CONFIG_FILE_SETTINGS@
@COMISO_ARPACK_CONFIG_FILE_SETTINGS@
@COMISO_CPLEX_CONFIG_FILE_SETTINGS@
@COMISO_EIGEN3_CONFIG_FILE_SETTINGS@
......@@ -21,6 +21,7 @@ set(my_sources
${CMAKE_CURRENT_SOURCE_DIR}/EigenLDLTSolverT.cc
${CMAKE_CURRENT_SOURCE_DIR}/Eigen_Tools.cc
${CMAKE_CURRENT_SOURCE_DIR}/GMM_Tools.cc
${CMAKE_CURRENT_SOURCE_DIR}/IterativeSolver.cc
${CMAKE_CURRENT_SOURCE_DIR}/IterativeSolverT.cc
${CMAKE_CURRENT_SOURCE_DIR}/MISolver.cc
${CMAKE_CURRENT_SOURCE_DIR}/MISolverT.cc
......
......@@ -23,9 +23,7 @@
\*===========================================================================*/
#include "ConstrainedSolver.hh"
#include <gmm/gmm.h>
#include "ConstrainedSolverT.cc"
namespace COMISO {
......@@ -116,3 +114,24 @@ find_gcd(std::vector<int>& _v_gcd, int& _n_ints)
}
// explicit instantiation
#include <CoMISo/Config/GmmTypes.hh>
#include <CoMISo/Config/StdTypes.hh>
namespace COMISO
{
using namespace COMISO_GMM;
using namespace COMISO_STD;
template void ConstrainedSolver::solve(WSRowMatrix&, WSColMatrix&,
DoubleVector&, DoubleVector&, IntVector&, double, bool, bool);
template void ConstrainedSolver::solve_const(const WSRowMatrix&,
const WSColMatrix&, DoubleVector&, const DoubleVector&, const IntVector&,
double, bool, bool);
template void COMISO::ConstrainedSolver::solve_const(const WSRowMatrix&,
const WSRowMatrix&, DoubleVector&, const IntVector&, double, bool, bool);
}//namespace COMISO_GMM
......@@ -110,7 +110,20 @@ show_timings()
}
}
}//namespace COMISO
//////////////////////////////////////////////////////////////////////////
// explicit instantiation
#include "EigenLDLTSolverT.cc"
namespace COMISO
{
template bool EigenLDLTSolver::update_system_gmm(const gmm::csc_matrix<double>&);
template bool EigenLDLTSolver::calc_system_gmm(const gmm::csc_matrix<double>&);
}//namespace COMISO
//=============================================================================
#endif // COMISO_EIGEN3_AVAILABLE
......
......@@ -778,8 +778,22 @@ void gmm_to_eigen( const gmm::csc_matrix<GMM_RealT,0>& _G, EIGEN_MatrixT& _E)
#endif
}
// this explicit instantiation does not match the call signature due to the
// partial specializations above
//template void gmm_to_eigen(const gmm::csc_matrix<double>&,
// Eigen::SparseMatrix<double>& );
// hence make a partial specialization that matches the main template signature
void gmm_to_eigen( const gmm::csc_matrix<double>& _G,
Eigen::SparseMatrix<double>& _E)
{
// and redirect to the above partial specialization
gmm_to_eigen< double, Eigen::SparseMatrix<double> > (_G, _E);
}
//=============================================================================
} // namespace COMISO
} // namespace COMISO_EIGEN
//=============================================================================
//=============================================================================
......
......@@ -1258,5 +1258,35 @@ void gmm_to_cholmod( const MatrixT& _A, cholmod_sparse* &_AC, cholmod_common* _c
#endif
//=============================================================================
} // namespace COMISO
} // namespace COMISO_GMM
//=============================================================================
#include <CoMISo/Config/GmmTypes.hh>
#include <CoMISo/Config/StdTypes.hh>
// explicit instantiation
namespace COMISO_GMM
{
using namespace COMISO_STD;
template void factored_to_quadratic(WSRowMatrix&, WSColMatrix&, DoubleVector&);
template void factored_to_quadratic(WSRowMatrix&, RSColMatrix&, DoubleVector&);
template void eliminate_csc_vars(const IntVector&, const DoubleVector&,
CSCMatrix&, DoubleVector&, DoubleVector&);
template void eliminate_csc_vars2(const IntVector&, const DoubleVector&,
CSCMatrix&, DoubleVector&, DoubleVector&);
template void eliminate_csc_vars2(const UIntVector&, const DoubleVector&,
CSCMatrix&, DoubleVector&, DoubleVector&);
template double residuum_norm(CSCMatrix& , DoubleVector&, DoubleVector&);
template void fix_var_csc_symmetric(const unsigned int, const double,
CSCMatrix&, DoubleVector&, DoubleVector&);
template void eliminate_vars_idx(const IntVector&, IntVector&, int, int);
}//namespace COMISO_GMM
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#include <CoMISo/Solver/IterativeSolverT.cc>
template class COMISO::IterativeSolverT<double>;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment