~mbogomilov/maus/devel3

« back to all changes in this revision

Viewing changes to src/common_cpp/Maths/Vector.cc

  • Committer: Durga Rajaram
  • Date: 2014-01-14 07:07:02 UTC
  • mfrom: (659.1.80 relcand)
  • Revision ID: durga@fnal.gov-20140114070702-2l1fuj1w6rraw7xe
Tags: MAUS-v0.7.6
MAUS-v0.7.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "gsl/gsl_vector_complex_double.h"
32
32
 
33
33
#include "Maths/Complex.hh"
34
 
#include "Interface/Squeal.hh"
 
34
#include "Utils/Exception.hh"
35
35
 
36
36
namespace MAUS {
37
37
 
152
152
const double& VectorBase<double, gsl_vector>::operator[](const size_t i)
153
153
    const {
154
154
  if (vector_ == NULL) {
155
 
    throw(Squeal(
156
 
      Squeal::recoverable,
 
155
    throw(Exception(
 
156
      Exception::recoverable,
157
157
      "Attempted to index an empty vector.",
158
158
      "MAUS::VectorBase<double, gsl_vector>::operator[]()"));
159
159
  }
165
165
const complex& VectorBase<complex, gsl_vector_complex>::operator[](
166
166
    const size_t i) const {
167
167
  if (vector_ == NULL) {
168
 
    throw(Squeal(
169
 
      Squeal::recoverable,
 
168
    throw(Exception(
 
169
      Exception::recoverable,
170
170
      "Attempted to index an empty vector.",
171
171
      "MAUS::VectorBase<complex, gsl_vector_complex>::operator[]()"));
172
172
  }
177
177
template <>
178
178
double& VectorBase<double, gsl_vector>::operator[](const size_t i) {
179
179
  if (vector_ == NULL) {
180
 
    throw(Squeal(
181
 
      Squeal::recoverable,
 
180
    throw(Exception(
 
181
      Exception::recoverable,
182
182
      "Attempted to index an empty vector.",
183
183
      "MAUS::VectorBase<double, gsl_vector>::operator[]()"));
184
184
  }
189
189
template <>
190
190
complex& VectorBase<complex, gsl_vector_complex>::operator[](const size_t i) {
191
191
  if (vector_ == NULL) {
192
 
    throw(Squeal(
193
 
      Squeal::recoverable,
 
192
    throw(Exception(
 
193
      Exception::recoverable,
194
194
      "Attempted to index an empty vector.",
195
195
      "MAUS::VectorBase<complex, gsl_vector_complex>::operator[]()"));
196
196
  }
238
238
VectorBase<double, gsl_vector> VectorBase<double, gsl_vector>::subvector(
239
239
    size_t begin_index, size_t end_index) const {
240
240
  if (vector_ == NULL) {
241
 
    throw(Squeal(
242
 
      Squeal::recoverable,
 
241
    throw(Exception(
 
242
      Exception::recoverable,
243
243
      "Attempted to create a subvector from an empty vector.",
244
244
      "MAUS::VectorBase<double, gsl_vector>::subvector()"));
245
245
  }
263
263
    size_t begin_index,
264
264
    size_t end_index) const {
265
265
  if (vector_ == NULL) {
266
 
    throw(Squeal(
267
 
      Squeal::recoverable,
 
266
    throw(Exception(
 
267
      Exception::recoverable,
268
268
      "Attempted to create a subvector from an empty vector.",
269
269
      "MAUS::VectorBase<complex, gsl_vector_complex>::subvector()"));
270
270
  }
296
296
      // vector is assigned to a null vector
297
297
      build_vector(rhs.vector_->size);
298
298
    } else if ((rhs.vector_ == NULL) || (vector_->size != rhs.vector_->size)) {
299
 
      throw(Squeal(Squeal::recoverable,
 
299
      throw(Exception(Exception::recoverable,
300
300
                   "Attempted to assign a vector of a different size.",
301
301
                   "VectorBase<double>::operator=()"));
302
302
    }
316
316
      // vector is assigned to a null vector
317
317
      build_vector(rhs.vector_->size);
318
318
    } else if ((rhs.vector_ == NULL) || (vector_->size != rhs.vector_->size)) {
319
 
      throw(Squeal(Squeal::recoverable,
 
319
      throw(Exception(Exception::recoverable,
320
320
                   "Attempted to assign a vector of a different size.",
321
321
                   "VectorBase<complex>::operator=()"));
322
322
    }
369
369
  if (rhs.vector_ != NULL) {
370
370
    size_t size = this->size();
371
371
    if (rhs.size() != size) {
372
 
      throw(Squeal(
373
 
        Squeal::recoverable,
 
372
      throw(Exception(
 
373
        Exception::recoverable,
374
374
        "Attempted to perform the product of two vectors of different sizes.",
375
375
        "MAUS::VectorBase<double, gsl_vector>::operator*="));
376
376
    }
377
377
 
378
378
    gsl_vector_mul(vector_, rhs.vector_);
379
379
  } else {
380
 
      throw(Squeal(
381
 
        Squeal::recoverable,
 
380
      throw(Exception(
 
381
        Exception::recoverable,
382
382
        "Attempted to multiply a vector by an empty vector.",
383
383
        "MAUS::VectorBase<double, gsl_vector>::operator*="));
384
384
  }
392
392
  if (rhs.vector_ != NULL) {
393
393
    size_t size = this->size();
394
394
    if (rhs.size() != size) {
395
 
      throw(Squeal(
396
 
        Squeal::recoverable,
 
395
      throw(Exception(
 
396
        Exception::recoverable,
397
397
        "Attempted to perform the product of two vectors of different sizes.",
398
398
        "MAUS::VectorBase<complex, gsl_vector_complex>::operator*="));
399
399
    }
400
400
 
401
401
    gsl_vector_complex_mul(vector_, rhs.vector_);
402
402
  } else {
403
 
      throw(Squeal(
404
 
        Squeal::recoverable,
 
403
      throw(Exception(
 
404
        Exception::recoverable,
405
405
        "Attempted to multiply a vector by an empty vector.",
406
406
        "MAUS::VectorBase<complex, gsl_vector_complex>::operator*="));
407
407
  }
414
414
  if (rhs.vector_ != NULL) {
415
415
    size_t size = this->size();
416
416
    if (rhs.size() != size) {
417
 
      throw(Squeal(
418
 
        Squeal::recoverable,
 
417
      throw(Exception(
 
418
        Exception::recoverable,
419
419
        "Attempted to perform the product of two vectors of different sizes.",
420
420
        "MAUS::VectorBase<double, gsl_vector>::operator/="));
421
421
    }
422
422
 
423
423
    gsl_vector_div(vector_, rhs.vector_);
424
424
  } else {
425
 
      throw(Squeal(
426
 
        Squeal::recoverable,
 
425
      throw(Exception(
 
426
        Exception::recoverable,
427
427
        "Attempted to divide a vector by an empty vector.",
428
428
        "MAUS::VectorBase<double, gsl_vector>::operator/="));
429
429
  }
437
437
  if (rhs.vector_ != NULL) {
438
438
    size_t size = this->size();
439
439
    if (rhs.size() != size) {
440
 
      throw(Squeal(
441
 
        Squeal::recoverable,
 
440
      throw(Exception(
 
441
        Exception::recoverable,
442
442
        "Attempted to perform the product of two vectors of different sizes.",
443
443
        "MAUS::VectorBase<complex, gsl_vector_complex>::operator/="));
444
444
    }
445
445
 
446
446
    gsl_vector_complex_div(vector_, rhs.vector_);
447
447
  } else {
448
 
      throw(Squeal(
449
 
        Squeal::recoverable,
 
448
      throw(Exception(
 
449
        Exception::recoverable,
450
450
        "Attempted to divide a vector by an empty vector.",
451
451
        "MAUS::VectorBase<complex, gsl_vector_complex>::operator/="));
452
452
  }