| 1 |
///////////////////////////////////////////////////////////// |
| 2 |
// // |
| 3 |
// Copyright (c) 2007-2017 by The University of Queensland // |
| 4 |
// Centre for Geoscience Computing // |
| 5 |
// http://earth.uq.edu.au/centre-geoscience-computing // |
| 6 |
// // |
| 7 |
// Primary Business: Brisbane, Queensland, Australia // |
| 8 |
// Licensed under the Open Software License version 3.0 // |
| 9 |
// http://www.apache.org/licenses/LICENSE-2.0 // |
| 10 |
// // |
| 11 |
///////////////////////////////////////////////////////////// |
| 12 |
|
| 13 |
// arbitrary size vectors |
| 14 |
#ifndef __NVECTOR_H |
| 15 |
#define __NVECTOR_H |
| 16 |
#include <iostream> |
| 17 |
|
| 18 |
|
| 19 |
using std::ostream; |
| 20 |
|
| 21 |
template<class T,int n> |
| 22 |
class nvector; |
| 23 |
|
| 24 |
template<class T,int n> |
| 25 |
nvector<T,n> operator/(const nvector<T,n>&, T); |
| 26 |
|
| 27 |
template<class T,int n> |
| 28 |
ostream& operator<<(ostream& ,const nvector<T,n>&); |
| 29 |
|
| 30 |
template<class T,int n> |
| 31 |
class nvector |
| 32 |
{ |
| 33 |
private: |
| 34 |
T m_data[n]; |
| 35 |
|
| 36 |
public: |
| 37 |
nvector(); |
| 38 |
nvector(const T); |
| 39 |
nvector(const nvector&); |
| 40 |
~nvector(); |
| 41 |
|
| 42 |
inline T operator[](int i) const {return m_data[i];}; |
| 43 |
inline T& operator[](int i){return m_data[i];}; |
| 44 |
|
| 45 |
nvector& operator=(const nvector&); |
| 46 |
nvector& operator-=(const nvector&); |
| 47 |
nvector& operator+=(const nvector&); |
| 48 |
nvector operator-(const nvector&) const; |
| 49 |
nvector operator+(const nvector&) const; |
| 50 |
|
| 51 |
friend nvector operator/ <>(const nvector&,T); |
| 52 |
static nvector unit(int); |
| 53 |
|
| 54 |
friend ostream& operator<< <>(ostream&,const nvector&); |
| 55 |
}; |
| 56 |
|
| 57 |
#include "nvector.hh" |
| 58 |
|
| 59 |
#endif //__NVECTOR_H |