4 #ifndef _ArnoldParameterVECTOR_H_
5 #define _ArnoldParameterVECTOR_H_
22 template<
size_t D,
typename T>
55 std::stringstream sstm;
75 T& operator[](
size_t i ) {
128 template<
size_t D,
typename T>
130 for (
size_t i = 0; i < D; i++) {
138 template<
size_t D,
typename T>
139 inline bool operator!=(ArnoldParameterVector<D, T> a, ArnoldParameterVector<D, T> b) {
144 template<
size_t D,
typename T>
145 inline bool operator<(ArnoldParameterVector<D, T> a, ArnoldParameterVector<D, T> b) {
146 for (
size_t i = 0; i < D; i++) {
147 if (a.getElement(i) >= b.getElement(i))
154 template<
size_t D,
typename T>
155 inline bool operator>(ArnoldParameterVector<D, T> a, ArnoldParameterVector<D, T> b) {
159 template<
size_t D,
typename T>
160 inline bool operator<=(ArnoldParameterVector<D, T> a, ArnoldParameterVector<D, T> b) {
164 template<
size_t D,
typename T>
165 inline bool operator>=(ArnoldParameterVector<D, T> a, ArnoldParameterVector<D, T> b) {
170 template<
size_t D,
typename T>
171 inline ArnoldParameterVector<D, T> operator+(ArnoldParameterVector<D, T> lhs, ArnoldParameterVector<D, T> rhs) {
172 ArnoldParameterVector<D, T> val = ArnoldParameterVector<D, T>(lhs);
174 for (
size_t i = 0; i < D; i++) {
175 val[i] += rhs.getElement(i);
181 template<
size_t D,
typename T>
182 inline ArnoldParameterVector<D, T> operator-(ArnoldParameterVector<D, T> lhs, ArnoldParameterVector<D, T> rhs) {
183 ArnoldParameterVector<D, T> val = ArnoldParameterVector<D, T>(lhs);
185 for (
size_t i = 0; i < D; i++) {
186 val[i] -= rhs.getElement(i);
192 template<
size_t D,
typename T>
193 inline ArnoldParameterVector<D, T> operator*(ArnoldParameterVector<D, T> lhs,
float rhs) {
194 ArnoldParameterVector<D, T> val = ArnoldParameterVector<D, T>(lhs);
199 template<
size_t D,
typename T>
200 inline ArnoldParameterVector<D, T> operator*(ArnoldParameterVector<D, T> lhs, ArnoldParameterVector<D, T> rhs) {
201 ArnoldParameterVector<D, T> val = ArnoldParameterVector<D, T>(lhs);
206 template<
size_t D,
typename T>
207 inline ArnoldParameterVector<D, T> operator/(ArnoldParameterVector<D, T> lhs,
float rhs) {
208 ArnoldParameterVector<D, T> val = ArnoldParameterVector<D, T>(lhs);
213 template<
size_t D,
typename T>
214 inline ArnoldParameterVector<D, T> operator/(ArnoldParameterVector<D, T> lhs, ArnoldParameterVector<D, T> rhs) {
215 ArnoldParameterVector<D, T> val = ArnoldParameterVector<D, T>(lhs);
220 template<
size_t D,
typename T>
224 for (
size_t i = 0; i < D; i++) {
225 val_s = (val) ? val[i] : 0;
227 m_elements[i] = val_s;
231 template<
size_t D,
typename T>
235 m_elements.reserve(D);
242 m_elements.push_back(T());
247 template<
size_t D,
typename T>
249 for (
size_t i = 0; i < val.
getDimension() && i < D; i++) {
255 template<
size_t D,
typename T>
256 ArnoldParameterVector<D, T>& ArnoldParameterVector<D, T>::operator+=(ArnoldParameterVector val) {
257 for (
size_t i = 0; i < val.getDimension() && i < D; i++) {
258 m_elements[i] += val.getElement(i);
264 template<
size_t D,
typename T>
265 ArnoldParameterVector<D, T>& ArnoldParameterVector<D, T>::operator-=(ArnoldParameterVector val) {
266 for (
size_t i = 0; i < val.getDimension() && i < D; i++) {
267 m_elements[i] -= val.getElement(i);
273 template<
size_t D,
typename T>
274 ArnoldParameterVector<D, T>& ArnoldParameterVector<D, T>::operator*=(
float val) {
275 for (
size_t i = 0; i < D; i++) {
276 m_elements[i] *= val;
282 template<
size_t D,
typename T>
283 ArnoldParameterVector<D, T>& ArnoldParameterVector<D, T>::operator*=(ArnoldParameterVector val) {
284 for (
size_t i = 0; i < val.getDimension() && i < D; i++) {
285 m_elements[i] *= val.getElement(i);
291 template<
size_t D,
typename T>
292 ArnoldParameterVector<D, T>& ArnoldParameterVector<D, T>::operator/=(
float val) {
293 for (
size_t i = 0; i < D; i++) {
294 m_elements[i] /= val;
300 template<
size_t D,
typename T>
301 ArnoldParameterVector<D, T>& ArnoldParameterVector<D, T>::operator/=(ArnoldParameterVector val) {
302 for (
size_t i = 0; i < val.getDimension() && i < D; i++) {
303 m_elements[i] /= val.getElement(i);
void resize(size_t dim)
Resizes the vector to a specific dimension.
Definition: ArnoldParameterVector.h:91
T m_elements[D]
The actual array contains the elements.
Definition: ArnoldParameterVector.h:117
~ArnoldParameterVector()
Destroys the vector.
Definition: ArnoldParameterVector.h:47
size_t getDimension()
Returns the dimension of this vector.
Definition: ArnoldParameterVector.h:85
ArnoldParameterVector(T *val=NULL)
Constructs a vector with the values passed as an array.
Definition: ArnoldParameterVector.h:221
std::string m_arnoldTypeName
The type name of arnold parameter.
Definition: ArnoldParameterVector.h:122
Defines a vector type for Arnold parameters, like color, vector etc.
Definition: ArnoldParameterVector.h:23
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
string getTypeName()
Says that this object is a vector for a arnold parameter.
Definition: ArnoldParameterVector.h:53
T * getElements()
Gets the pointer to corresponding array.
Definition: ArnoldParameterVector.h:104
void setElement(size_t i, T val)
Sets the value of a element.
Definition: ArnoldParameterVector.h:111
T getElement(size_t i)
Gets the nth element.
Definition: ArnoldParameterVector.h:98