Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/LinearAlgebra/Matrix.cpp

    r5b4605 r80cecb5  
     1/*
     2 * Project: MoleCuilder
     3 * Description: creates and alters molecular systems
     4 * Copyright (C)  2010 University of Bonn. All rights reserved.
     5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
     6 */
     7
    18/*
    29 * Matrix.cpp
     
    512 *      Author: crueger
    613 */
     14
     15// include config.h
     16#ifdef HAVE_CONFIG_H
     17#include <config.h>
     18#endif
     19
     20#include "Helpers/MemDebug.hpp"
    721
    822#include "LinearAlgebra/Matrix.hpp"
     
    108122}
    109123
     124void Matrix::rotation(const double x, const double y, const double z)
     125{
     126  set(0,0, cos(y)*cos(z));
     127  set(0,1, cos(z)*sin(x)*sin(y) - cos(x)*sin(z));
     128  set(0,2, cos(x)*cos(z)*sin(y) + sin(x) * sin(z));
     129  set(1,0, cos(y)*sin(z));
     130  set(1,1, cos(x)*cos(z) + sin(x)*sin(y)*sin(z));
     131  set(1,2, -cos(z)*sin(x) + cos(x)*sin(y)*sin(z));
     132  set(2,0, -sin(y));
     133  set(2,1, cos(y)*sin(x));
     134  set(2,2, cos(x)*cos(y));
     135}
     136
    110137Matrix &Matrix::operator=(const Matrix &src){
    111138  if(&src!=this){
     
    213240
    214241
    215 void Matrix::transpose()
     242Matrix &Matrix::transpose()
    216243{
    217244  double tmp;
     
    219246    for (int j=i+1;j<NDIM;j++) {
    220247      tmp = at(j,i);
     248      at(j,i) = at(i,j);
    221249      at(i,j) = tmp;
    222       at(j,i) = tmp;
    223     }
     250    }
     251  return *this;
    224252}
    225253
     
    253281  gsl_eigen_symmv_free(T);
    254282  gsl_matrix_memcpy(content->content, evec);
     283  gsl_matrix_free(evec);
    255284  Vector evalues(gsl_vector_get(eval,0), gsl_vector_get(eval,1), gsl_vector_get(eval,2));
     285  gsl_vector_free(eval);
    256286  return evalues;
    257287}
     
    315345
    316346Vector operator*(const Matrix &mat,const Vector &vec){
    317   gsl_vector *res = gsl_vector_calloc(NDIM);
    318   gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content->content, vec.content->content, 0.0, res);
    319   VectorContent *content = new VectorContent();
    320   content->content = res;
    321   return Vector(content);
     347  Vector res;
     348  gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content->content, vec.content->content, 0.0, res.content->content);
     349  return res;
    322350}
    323351
Note: See TracChangeset for help on using the changeset viewer.