mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 15:51:12 +00:00
Imported Healpix, cfitsio, cosmotool. Added cmake tool to build dependencies (cfitsio, hdf5, netcdf, boost, healpix, gsl, ..). Adjusted CMakeLists.txt
This commit is contained in:
parent
4bfb62f177
commit
51f6798f88
241 changed files with 243806 additions and 0 deletions
83
external/cosmotool/src/field.hpp
vendored
Normal file
83
external/cosmotool/src/field.hpp
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
#ifndef __COSMOTOOL_FIELD
|
||||
#define __COSMOTOOL_FIELD
|
||||
|
||||
#include "config.hpp"
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
namespace CosmoTool {
|
||||
|
||||
template<typename BaseType>
|
||||
struct ScalarField
|
||||
{
|
||||
BaseType value;
|
||||
};
|
||||
|
||||
template<typename BaseType, int N>
|
||||
struct VectorField
|
||||
{
|
||||
BaseType vec[N];
|
||||
|
||||
VectorField& operator=(const VectorField& a)
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
vec[i] = a.vec[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
VectorField()
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
vec[i] = 0;
|
||||
}
|
||||
|
||||
VectorField(double a)
|
||||
{
|
||||
assert(a == 0);
|
||||
for (int i = 0; i < N; i++)
|
||||
vec[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename BaseType, int N>
|
||||
VectorField<BaseType,N> operator*(BaseType s, const VectorField<BaseType,N>& a)
|
||||
{
|
||||
VectorField<BaseType,N> v;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
v.vec[i] = a.vec[i]*s;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename BaseType, int N>
|
||||
VectorField<BaseType,N> operator+(const VectorField<BaseType,N>& a, const VectorField<BaseType,N>& b)
|
||||
{
|
||||
VectorField<BaseType,N> v;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
v.vec[i] = a.vec[i]+b.vec[i];
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename BaseType, int N>
|
||||
VectorField<BaseType,N>& operator+=(VectorField<BaseType,N>& a, const VectorField<BaseType,N>& b)
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
a.vec[i]+=b.vec[i];
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename BaseType, int N>
|
||||
std::ostream& operator<<(std::ostream& s, const CosmoTool::VectorField<BaseType,N>& a)
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
s << a.vec[i] << " " ;
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue