Changeset 325390 for src/vector.cpp


Ignore:
Timestamp:
Jun 25, 2010, 1:44:07 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
c94eeb
Parents:
923b6c
git-author:
Tillmann Crueger <crueger@…> (06/25/10 10:52:58)
git-committer:
Tillmann Crueger <crueger@…> (06/25/10 13:44:07)
Message:

Started work on basic matrix class to be used with Vector class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    r923b6c r325390  
    88
    99#include "vector.hpp"
     10#include "Matrix.hpp"
    1011#include "verbose.hpp"
    1112#include "World.hpp"
    1213#include "Helpers/Assert.hpp"
    1314#include "Helpers/fast_functions.hpp"
     15#include "Exceptions/MathException.hpp"
    1416
    1517#include <iostream>
     
    4850  gsl_vector_set(content,2,x3);
    4951};
     52
     53Vector::Vector(gsl_vector *_content) :
     54  content(_content)
     55{}
    5056
    5157/**
     
    458464};
    459465
     466Vector &Vector::operator*=(const Matrix &mat){
     467  (*this) = mat*(*this);
     468  return *this;
     469}
     470
     471Vector operator*(const Matrix &mat,const Vector &vec){
     472  gsl_vector *res = gsl_vector_calloc(NDIM);
     473  gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content, vec.content, 0.0, res);
     474  return Vector(res);
     475}
     476
     477
    460478/** Factors given vector \a a times \a m.
    461479 * \param a vector
     
    548566void Vector::MatrixMultiplication(const double * const M)
    549567{
    550   Vector tmp;
    551   // do the matrix multiplication
    552   for(int i=NDIM;i--;)
    553     tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2);
    554 
    555   (*this) = tmp;
     568  (*this) *= Matrix(M);
    556569};
    557570
     
    561574bool Vector::InverseMatrixMultiplication(const double * const A)
    562575{
     576  /*
    563577  double B[NDIM*NDIM];
    564578  double detA = RDET3(A);
     
    582596    return true;
    583597  } else {
     598    return false;
     599  }
     600  */
     601  Matrix mat = Matrix(A);
     602  try{
     603    (*this) *= mat.invert();
     604    return true;
     605  }
     606  catch(MathException &excpt){
    584607    return false;
    585608  }
Note: See TracChangeset for help on using the changeset viewer.