\hypertarget{vector_8hpp_source}{}\doxysection{vector.\+hpp}
\label{vector_8hpp_source}\index{src/vector.hpp@{src/vector.hpp}}
\mbox{\hyperlink{vector_8hpp}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#ifndef VECTOR\_HPP}}
\DoxyCodeLine{2 \textcolor{preprocessor}{\#define VECTOR\_HPP}}
\DoxyCodeLine{3 }
\DoxyCodeLine{4 \textcolor{preprocessor}{\#include <iostream>}}
\DoxyCodeLine{5 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{debug_8hpp}{debug.hpp}}"{}}}
\DoxyCodeLine{6 }
\DoxyCodeLine{7 \textcolor{keyword}{using namespace }std;}
\DoxyCodeLine{8 }
\DoxyCodeLine{9 \textcolor{keyword}{using} \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} = double;\textcolor{comment}{//float;}}
\DoxyCodeLine{10 }
\DoxyCodeLine{11 \textcolor{preprocessor}{\#ifdef DEBUG}}
\DoxyCodeLine{12 \textcolor{keyword}{struct }\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}}\{}
\DoxyCodeLine{13   \textcolor{keywordtype}{size\_t} n;}
\DoxyCodeLine{14   \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}* data;}
\DoxyCodeLine{15   \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}\& operator[](\textcolor{keywordtype}{size\_t} i);}
\DoxyCodeLine{16 \};}
\DoxyCodeLine{17 }
\DoxyCodeLine{18 \textcolor{keyword}{inline} \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}\&}
\DoxyCodeLine{19 Vector::operator[](\textcolor{keywordtype}{size\_t} i)\{}
\DoxyCodeLine{20   \mbox{\hyperlink{debug_8hpp_a3153a272f18d0f805028fce7e4337b53}{assert}}(i<n);}
\DoxyCodeLine{21   \textcolor{keywordflow}{return} data[i];}
\DoxyCodeLine{22 \}}
\DoxyCodeLine{23 }
\DoxyCodeLine{24 \textcolor{keyword}{inline} \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}}}
\DoxyCodeLine{25 \mbox{\hyperlink{vector_8hpp_a624100980bbf31adef9cc6bfd6e89738}{init\_vector}}(\textcolor{keywordtype}{size\_t} n)\{}
\DoxyCodeLine{26   \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} v;}
\DoxyCodeLine{27   v.n=n;}
\DoxyCodeLine{28   v.data=\textcolor{keyword}{new} \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}[n];}
\DoxyCodeLine{29   \textcolor{keywordflow}{return} v;}
\DoxyCodeLine{30 \}}
\DoxyCodeLine{31 }
\DoxyCodeLine{32 \textcolor{keyword}{inline} \textcolor{keywordtype}{void}}
\DoxyCodeLine{33 \mbox{\hyperlink{vector_8hpp_a34a7c651953c188bf41e94dee669ad70}{delete\_vector}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} v)\{}
\DoxyCodeLine{34   \textcolor{keyword}{delete}[] v.data;}
\DoxyCodeLine{35 \}}
\DoxyCodeLine{36 }
\DoxyCodeLine{37 \textcolor{keyword}{inline} \textcolor{keywordtype}{bool}}
\DoxyCodeLine{38 is\_null(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} v)\{}
\DoxyCodeLine{39   \textcolor{keywordflow}{return} v.n==0;}
\DoxyCodeLine{40 \}}
\DoxyCodeLine{41 }
\DoxyCodeLine{42 \textcolor{keyword}{static} \textcolor{keyword}{const} \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} NullVector=\{0,\textcolor{keyword}{nullptr}\};}
\DoxyCodeLine{43 }
\DoxyCodeLine{44 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{45 \textcolor{keyword}{using} \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}}=\mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}*;}
\DoxyCodeLine{46 }
\DoxyCodeLine{47 \textcolor{keyword}{inline} \mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}}}
\DoxyCodeLine{48 \mbox{\hyperlink{vector_8hpp_a624100980bbf31adef9cc6bfd6e89738}{init\_vector}}(\textcolor{keywordtype}{size\_t} n)\{}
\DoxyCodeLine{49   \textcolor{keywordflow}{return} \textcolor{keyword}{new} \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}}[n];}
\DoxyCodeLine{50 \}}
\DoxyCodeLine{51 }
\DoxyCodeLine{52 \textcolor{keyword}{inline} \textcolor{keywordtype}{void}}
\DoxyCodeLine{53 \mbox{\hyperlink{vector_8hpp_a34a7c651953c188bf41e94dee669ad70}{delete\_vector}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} v)\{}
\DoxyCodeLine{54   \textcolor{keyword}{delete}[] v;}
\DoxyCodeLine{55 \}}
\DoxyCodeLine{56 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{57 }
\DoxyCodeLine{58 \textcolor{keyword}{inline} \textcolor{keywordtype}{void}}
\DoxyCodeLine{59 \mbox{\hyperlink{vector_8hpp_a01121fb497c32a2fc0deee30071180ff}{display}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} v,\textcolor{keywordtype}{size\_t} n)\{}
\DoxyCodeLine{60   \textcolor{keywordflow}{if}(n==0)\{}
\DoxyCodeLine{61     cout<<\textcolor{stringliteral}{"{}[]"{}}<<endl;}
\DoxyCodeLine{62     \textcolor{keywordflow}{return};}
\DoxyCodeLine{63   \}}
\DoxyCodeLine{64   cout<<\textcolor{charliteral}{'['}<<v[0];}
\DoxyCodeLine{65   \textcolor{keywordflow}{for}(\textcolor{keywordtype}{size\_t} i=1;i<n;++i)\{}
\DoxyCodeLine{66     cout<<\textcolor{charliteral}{','}<<v[i];}
\DoxyCodeLine{67   \}}
\DoxyCodeLine{68   cout<<\textcolor{charliteral}{']'}<<endl;}
\DoxyCodeLine{69 \}}
\DoxyCodeLine{70 }
\DoxyCodeLine{71 \textcolor{keyword}{inline} \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{72 \mbox{\hyperlink{vector_8hpp_a2edc1ce8353b41e8b9120d90e76c9481}{argmax}}(\mbox{\hyperlink{vector_8hpp_ab9855a300a7759f4c0f85067d44e4c38}{Vector}} v,\textcolor{keywordtype}{size\_t} n)\{}
\DoxyCodeLine{73   \mbox{\hyperlink{debug_8hpp_a3153a272f18d0f805028fce7e4337b53}{assert}}(n>0);}
\DoxyCodeLine{74   \textcolor{keywordtype}{size\_t} imax=0;}
\DoxyCodeLine{75   \mbox{\hyperlink{vector_8hpp_a4b04262b81aa7d31eb5d2f607e2a35de}{Real}} vmax=v[0];}
\DoxyCodeLine{76   \textcolor{keywordflow}{for}(\textcolor{keywordtype}{size\_t} i=1;i<n;++i)\{}
\DoxyCodeLine{77     \textcolor{keywordflow}{if}(v[i]>vmax)\{}
\DoxyCodeLine{78       vmax=v[i];}
\DoxyCodeLine{79       imax=i;}
\DoxyCodeLine{80     \}}
\DoxyCodeLine{81   \}}
\DoxyCodeLine{82   \textcolor{keywordflow}{return} imax;}
\DoxyCodeLine{83 \}}
\DoxyCodeLine{84 }
\DoxyCodeLine{85 \textcolor{keyword}{inline} \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{86 \mbox{\hyperlink{vector_8hpp_a8a3da36f32f258d0fcd5c8453fcc9c58}{indice2}}(\textcolor{keywordtype}{size\_t} i,\textcolor{keywordtype}{size\_t} j,\textcolor{keywordtype}{size\_t} nj)\{}
\DoxyCodeLine{87   \textcolor{keywordflow}{return} i*nj+j;}
\DoxyCodeLine{88 \}}
\DoxyCodeLine{89 }
\DoxyCodeLine{90 \textcolor{keyword}{inline} \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{91 \mbox{\hyperlink{vector_8hpp_a6df97fe6a0623e6b4bac1ba311a0a9de}{indice3}}(\textcolor{keywordtype}{size\_t} i,\textcolor{keywordtype}{size\_t} j,\textcolor{keywordtype}{size\_t} k,\textcolor{keywordtype}{size\_t} nj,\textcolor{keywordtype}{size\_t} nk)\{}
\DoxyCodeLine{92   \textcolor{keywordflow}{return} (i*nj+j)*nk+k;}
\DoxyCodeLine{93 \}}
\DoxyCodeLine{94 }
\DoxyCodeLine{95 \textcolor{keyword}{inline} \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{96 \mbox{\hyperlink{vector_8hpp_a04bfed1c3222805726b019f3bbe185bc}{indice4}}(\textcolor{keywordtype}{size\_t} i,\textcolor{keywordtype}{size\_t} j,\textcolor{keywordtype}{size\_t} k,\textcolor{keywordtype}{size\_t} l,\textcolor{keywordtype}{size\_t} nj,\textcolor{keywordtype}{size\_t} nk,\textcolor{keywordtype}{size\_t} nl)\{}
\DoxyCodeLine{97   \textcolor{keywordflow}{return} ((i*nj+j)*nk+k)*nl+l;}
\DoxyCodeLine{98 \}}
\DoxyCodeLine{99 }
\DoxyCodeLine{100 \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
