[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29131] branches/soc-2010-rohith291991/ intern/comiso/Solver: Small commit.
Rohith B V
rohith291991 at gmail.com
Tue Jun 1 19:05:22 CEST 2010
Revision: 29131
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29131
Author: rohith291991
Date: 2010-06-01 19:05:22 +0200 (Tue, 01 Jun 2010)
Log Message:
-----------
Small commit. Added two files to comiso.
Modified Paths:
--------------
branches/soc-2010-rohith291991/intern/comiso/Solver/constraint.cc
Added Paths:
-----------
branches/soc-2010-rohith291991/intern/comiso/Solver/common.h
Added: branches/soc-2010-rohith291991/intern/comiso/Solver/common.h
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/Solver/common.h (rev 0)
+++ branches/soc-2010-rohith291991/intern/comiso/Solver/common.h 2010-06-01 17:05:22 UTC (rev 29131)
@@ -0,0 +1,12 @@
+#include "Eigen/Core"
+#include "Eigen/Sparse"
+
+using namespace Eigen;
+
+// ----- Space for other typedefs as needed -----
+
+typedef SparseMatrix<double,ColMajor> SparseXdc;
+typedef SparseMatrix<double,RowMajor> SparseXdr;
+
+bool choleskySolve(SparseXd A, VectorXd b, VectorXd& x);
+bool MISolve(SparseXd A, VectorXd b, VectorXd& x, SparseXd constraints,std::vector<int> roundIndices,int maxIter=10000, double precision=1e-7);
Modified: branches/soc-2010-rohith291991/intern/comiso/Solver/constraint.cc
===================================================================
--- branches/soc-2010-rohith291991/intern/comiso/Solver/constraint.cc 2010-06-01 16:49:11 UTC (rev 29130)
+++ branches/soc-2010-rohith291991/intern/comiso/Solver/constraint.cc 2010-06-01 17:05:22 UTC (rev 29131)
@@ -1,25 +1,25 @@
/*===========================================================================*\
-* *
-* CoMISo *
-* Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen *
-* www.rwth-graphics.de *
-* *
-*---------------------------------------------------------------------------*
-* This file is part of CoMISo. *
-* *
-* CoMISo is free software: you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation, either version 3 of the License, or *
-* (at your option) any later version. *
-* *
-* CoMISo is distributed in the hope that it will be useful, *
-* but WITHOUT ANY WARRANTY; without even the implied warranty of *
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-* GNU General Public License for more details. *
-* *
-* You should have received a copy of the GNU General Public License *
-* along with CoMISo. If not, see <http://www.gnu.org/licenses/>. *
-* *
+ * *
+ * CoMISo *
+ * Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen *
+ * www.rwth-graphics.de *
+ * *
+ *---------------------------------------------------------------------------*
+ * This file is part of CoMISo. *
+ * *
+ * CoMISo is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * CoMISo is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with CoMISo. If not, see <http://www.gnu.org/licenses/>. *
+ * *
\*===========================================================================*/
#define ACG_CONSTRAINEDSOLVER_C
@@ -35,889 +35,878 @@
namespace ACG{
+void solve(SparseXd& _constraints, SparseXd& _B, VectorXd _x ,VectorXd _idx_to_round,
+ double _reg_factor,
+ bool _show_miso_settings,
+ bool _show_timings )
+{
+ int nrows = B.rows();
+ int ncols = B.cols()
+ int ncons = constraints.rows();
- void ConstrainedSolver::
- solve(SparseXd& _constraints,
- SparseXd& _B, VectorXd _x,
- VectorXd _idx_to_round,
- double _reg_factor,
- bool _show_miso_settings,
- bool _show_timings )
- {
- int nrows = B.rows();
- int ncols = B.cols();
- int ncons = constraints.rows();
+ if( _show_timings) std::cerr << __FUNCTION__ << "\n Initial dimension: " << nrows << " x " << ncols << ", number of constraints: " << ncons << std::endl;
+
+ // StopWatch for Timings
+ ACG::StopWatch sw, sw2; sw.start(); sw2.start();
- if( _show_timings) std::cerr << __FUNCTION__ << "\n Initial dimension: " << nrows << " x " << ncols << ", number of constraints: " << ncons << std::endl;
+ // c_elim[i] = index of variable which is eliminated in condition i
+ // or -1 if condition is invalid
+ std::vector<int> c_elim( ncons);
- // StopWatch for Timings
- ACG::StopWatch sw, sw2; sw.start(); sw2.start();
+ // apply sparse gauss elimination to make subsequent _constraints independent
- // c_elim[i] = index of variable which is eliminated in condition i
- // or -1 if condition is invalid
- std::vector<int> c_elim( ncons);
+ //TODO
+ make_constraints_independent( _constraints, _idx_to_round, c_elim);
+ double time_gauss = sw.stop()/1000.0; sw.start();
- // apply sparse gauss elimination to make subsequent _constraints independent
+ // eliminate conditions and return column matrix Bcol
+ SparseXd Bcol( nrows, ncols);
+ // reindexing vector
+ std::vector<int> new_idx;
- // TODO
- make_constraints_independent( _constraints, _idx_to_round, c_elim);
+ //TODO
+ eliminate_constraints( _constraints, _B, _idx_to_round, c_elim, new_idx, Bcol);
+ double time_eliminate = sw.stop()/1000.0; sw.start();
+ if( _show_timings) std::cerr << "Eliminated dimension: " << Bcol.rows() << " x " << Bcol.cols() << std::endl;
- double time_gauss = sw.stop()/1000.0; sw.start();
+ // setup and solve system
+ //TODO
+ double time_setup = setup_and_solve_system( Bcol, _x, _idx_to_round, _reg_factor, _show_miso_settings);
- // eliminate conditions and return column matrix Bcol
- SparseXd Bcol( nrows, ncols);
+ // double time_setup_solve = sw.stop()/1000.0; sw.start();
+
+ // restore eliminated vars to fulfill the given conditions
+ //TODO
+ restore_eliminated_vars( _constraints, _x, c_elim, new_idx);
- // reindexing vector
- std::vector<int> new_idx;
+ double time_resubstitute = sw.stop()/1000.0; sw.start();
+ // double time_total = sw2.stop()/1000.0;
- //TODO
- eliminate_constraints( _constraints, _B, _idx_to_round, c_elim, new_idx, Bcol);
+ if( _show_timings) std::cerr << "Timings: \n\t" <<
+ "Gauss Elimination " << time_gauss << " s\n\t" <<
+ "System Elimination " << time_eliminate << " s\n\t" <<
+ "Setup " << time_setup << " s\n\t" <<
+ // "Setup + Mi-Solver " << time_setup_solve << " s\n\t" <<
+ "Resubstitution " << time_resubstitute << " s\n\t" << std::endl << std::endl;
+ //"Total " << time_total << std::endl;
+}
- double time_eliminate = sw.stop()/1000.0; sw.start();
- if( _show_timings) std::cerr << "Eliminated dimension: " << Bcol.rows() << " x " << Bcol.cols() << std::endl;
+//-----------------------------------------------------------------------------
- // setup and solve system
- //TODO
- double time_setup = setup_and_solve_system( Bcol, _x, _idx_to_round, _reg_factor, _show_miso_settings);
- // double time_setup_solve = sw.stop()/1000.0; sw.start();
- // restore eliminated vars to fulfill the given conditions
- //TODO
- restore_eliminated_vars( _constraints, _x, c_elim, new_idx);
+void solve(
+ SparseXd& _constraints,
+ SparseXd& _A,
+ VectorXd& _x,
+ VectorXd& _rhs,
+ VectorXi& _idx_to_round,
+ double _reg_factor,
+ bool _show_miso_settings,
+ bool _show_timings )
+{
+ int nrows = _A.rows();
+ int ncols = _A.cols();
+ int ncons = _constraints.rows();
- double time_resubstitute = sw.stop()/1000.0; sw.start();
+ if( _show_timings) std::cerr << __FUNCTION__ << "\n Initital dimension: " << nrows << " x " << ncols << ", number of constraints: " << ncons << std::endl;
- // double time_total = sw2.stop()/1000.0;
+ // StopWatch for Timings
+ ACG::StopWatch sw, sw2; sw.start(); sw2.start();
- if( _show_timings) std::cerr << "Timings: \n\t" <<
- "Gauss Elimination " << time_gauss << " s\n\t" <<
- "System Elimination " << time_eliminate << " s\n\t" <<
- "Setup " << time_setup << " s\n\t" <<
- // "Setup + Mi-Solver " << time_setup_solve << " s\n\t" <<
- "Resubstitution " << time_resubstitute << " s\n\t" << std::endl << std::endl;
- //"Total " << time_total << std::endl;
- }
+ // c_elim[i] = index of variable which is eliminated in condition i
+ // or -1 if condition is invalid
+ std::vector<int> c_elim( ncons);
+ // apply sparse gauss elimination to make subsequent _conditions independent
+ //TODO
+ make_constraints_independent( _constraints, _idx_to_round, c_elim);
- //-----------------------------------------------------------------------------
+ double time_gauss = sw.stop()/1000.0; sw.start();
+ // re-indexing vector
+ std::vector<int> new_idx;
+ gmm::csc_matrix< double > Acsc;
- void ConstrainedSolver::
- solve(
- SparseXd& _constraints,
- SparseXd& _A,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list