22 #include <tjutils/tjutils.h>
23 #include <tjutils/tjcomplex.h>
24 #include <tjutils/tjtools.h>
25 #include <tjutils/tjstring.h>
26 #include <tjutils/tjlog.h>
37 static const char* get_compName();
50 template<
class T>
class tjvector :
public STD_vector<T> {
115 for(
unsigned int i=0; i<
length(); i++) result[i]+=w[i];
125 for(
unsigned int i=0; i<
length(); i++) result[i]-=w[i];
135 for(
unsigned int i=0; i<
length(); i++) result[i]*=w[i];
145 for(
unsigned int i=0; i<
length(); i++) result[i]/=w[i];
155 for(
unsigned int i=0; i<
length(); i++) result[i]=-result[i];
165 for(
unsigned int i=0; i<v.size(); i++) result[i]+=s;
183 for(
unsigned int i=0; i<v.size(); i++) result[i]=s-result[i];
202 for(
unsigned int i=0; i<v.size(); i++) result[i]=result[i]*s;
221 for(
unsigned int i=0; i<v.size(); i++) result[i]=s/result[i];
230 return (T(1)/s)*(*this);
401 int load(
const STD_string& fname);
410 int write(
const STD_string& fname,
fopenMode mode=overwriteMode, LONGEST_INT nelements=-1)
const;
424 return s <<
"(" << v.size() <<
")=" << v.
printbody();
431 static T* allocate_memory(
unsigned int nelements) {
return new T[nelements];}
435 mutable T* c_array_cache;
468 struct svector :
public STD_vector<STD_string> {
472 svector(
const STD_vector<STD_string>& sv) {svector::operator = (sv);}
473 svector& operator = (
const STD_vector<STD_string>& sv) {STD_vector<STD_string>::operator = (sv);
return *
this;}
476 unsigned char* c_array()
const {
return 0;}
477 svector& set_c_array(
const unsigned char*,
unsigned int) {
return *
this;}
478 static unsigned char* allocate_memory(
unsigned int) {
return 0;}
481 STD_string printbody()
const;
487 STD_complex* interpolate1D(
const STD_complex* data,
unsigned int oldsize,
unsigned int newsize,
float subpixel_shift);
488 float* interpolate1D(
const float* olddata,
unsigned int oldsize,
unsigned int newsize,
float subpixel_shift);
489 double* interpolate1D(
const double* olddata,
unsigned int oldsize,
unsigned int newsize,
float subpixel_shift);
490 int* interpolate1D(
const int* olddata,
unsigned int oldsize,
unsigned int newsize,
float subpixel_shift);
501 STD_vector<T> result; result.resize(src.size());
503 for(
typename STD_list<T>::const_iterator it=src.begin(); it!=src.end(); ++it) {
570 #ifndef NO_FILEHANDLING
578 svector browse_dir(
const STD_string& dirname,
bool only_dirs=
false,
bool discard_dotfiles=
false);
tjvector< T > & operator+=(const STD_vector< T > &v)
tjvector(unsigned int n=0)
tjvector(const tjvector< T > &tv)
const T * c_array() const
tjvector< T > operator+(const STD_vector< T > &w) const
int load(const STD_string &fname)
tjvector< T > & operator-=(const STD_vector< T > &v)
unsigned int fill_linear(const T &min, const T &max)
int write(const STD_string &fname, fopenMode mode=overwriteMode, LONGEST_INT nelements=-1) const
tjvector< T > & operator=(const T &value)
tjvector(const T *array, unsigned int n)
tjvector< T > operator/(const STD_vector< T > &w) const
tjvector< T > range(unsigned int startindex, unsigned int endindex) const
tjvector< T > & operator*=(const STD_vector< T > &v)
friend STD_ostream & operator<<(STD_ostream &s, const tjvector< T > &v)
tjvector(const STD_vector< T > &v)
STD_string printbody() const
tjvector & interpolate(unsigned int newsize, float subpixel_shift=0.0)
virtual tjvector< T > & resize(unsigned int newsize)
unsigned int length() const
tjvector< T > operator*(const STD_vector< T > &w) const
tjvector< T > & operator/=(const STD_vector< T > &v)
tjvector & set_c_array(const unsigned char *array, unsigned int n)
tjvector< T > operator-() const
tjvector< float > fvector
STD_vector< T > list2vector(const STD_list< T > &src)
tjvector< double > dvector
cvector real2complex(const fvector &fv)
svector browse_dir(const STD_string &dirname, bool only_dirs=false, bool discard_dotfiles=false)
fvector dvector2fvector(const dvector &dv)
fvector phase(const cvector &cv)
dvector fvector2dvector(const fvector &fv)
fvector real(const cvector &cv)
fvector amplitude(const cvector &cv)
STD_string tokenstring(const svector &tokens, unsigned int linewidth=_DEFAULT_LINEWIDTH_)
tjvector< STD_complex > cvector
svector tokens(const STD_string &tokenstring, char custom_separator=0, char escape_begin='"', char escape_end='"')
fvector imag(const cvector &cv)