last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 1998-2004 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00006 * 00007 * The CVR-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the BSD License. 00009 * 00010 * All rights reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions are met: 00014 * 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 00022 * 3. Neither the name of the authors nor the names of its contributors may be 00023 * used to endorse or promote products derived from this software without 00024 * specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 */ 00038 00039 /** 00040 * \file cvrLattice1D.h 00041 * Contains the template class cvr::lattice1D, which is the 00042 * mathematical version of cvr::genericLattice1D. 00043 * Some arithmetical operations have been added. 00044 * \author Pablo Alvarado 00045 * \date 17.01.2008 00046 * 00047 * $Id: cvrLattice1D.h,v 1.8 2007/04/06 01:18:41 alvarado Exp $ 00048 */ 00049 00050 #ifndef _CVR_LATTICE_1D_H_ 00051 #define _CVR_LATTICE_1D_H_ 00052 00053 #define _CVR_GENERIC_LATTICE_1_D_DONT_INSTANTIATE_REQUEST 00054 #include "cvrGenericLattice1D.h" 00055 #undef _CVR_GENERIC_LATTICE_1_D_DONT_INSTANTIATE_REQUEST 00056 00057 namespace cvr { 00058 /** 00059 * Mathematical lattice1D container class. 00060 * 00061 * This container is inspired on mathematical integer lattices, at least with 00062 * respect to the indices, which are taken from \f$Z^n\f$ in the general 00063 * case with $n=1$ in this particular case. 00064 * 00065 * You can consider this a generalization of a cvr::vector, in which the 00066 * index of the first element is not necessarily zero, but a negative or 00067 * positive value. 00068 00069 * The main goal of this class is to provide a \b fast implementation for 00070 * random access containers, addressable with negative indices, like filter 00071 * kernels, and since speed is the premise, it is achieved at some memory 00072 * costs. This means this class has some storage overhead in order to 00073 * provide some information at zero time, like size, first and last indices 00074 * the begin and end iterators, etc., which is only possible by storing them 00075 * directly. 00076 * 00077 * Additionally to all functionality of the genericLattice1D, this class 00078 * provides additional arithmetical and mathematical operations. 00079 * 00080 * The following types are supported by cvr::lattice1D: 00081 * - ubyte 00082 * - byte 00083 * - char 00084 * - uint16 00085 * - int16 00086 * - int32 00087 * - uint32 00088 * - long 00089 * - float 00090 * - double 00091 * - rgbaPixel 00092 * - frgbPixel 00093 * - ipoint 00094 * - fpoint 00095 * - dpoint 00096 * - ipoint3D 00097 * - fpoint3D 00098 * - dpoint3D 00099 * - fcomplex 00100 * - dcomplex 00101 * 00102 * This restriction is done to avoid the typical template code explosion 00103 * due to frequently used types in the library. If you need the lattice1D as 00104 * container of any other type, consider using cvr::genericLattice1D. 00105 * 00106 * The lattice1D class is a container class implemented as template, where 00107 * the template type T denotes the type of the elements. It is by no means a 00108 * generic container, since the types it supports must fulfill many 00109 * requirements, specially support for all arithmetical operators, and the 00110 * types supported are explicitely instantiated in the library. 00111 * 00112 * @ingroup gAggregate 00113 * @ingroup gLinearAlgebra 00114 */ 00115 template<typename T> 00116 class lattice1D : public genericLattice1D<T> { 00117 public: 00118 00119 /** 00120 * \name Internal types and classes 00121 */ 00122 //@{ 00123 00124 /** 00125 * Exception thrown when a constant reference is violated. 00126 */ 00127 typedef cvr::constReferenceException constReferenceException; 00128 00129 /** 00130 * Type of the genericLattice1D elements. 00131 */ 00132 typedef typename genericLattice1D<T>::value_type value_type; 00133 00134 /** 00135 * Return type of the size() member 00136 */ 00137 typedef typename genericLattice1D<T>::size_type size_type; 00138 00139 /** 00140 * Pointer to value_type 00141 */ 00142 typedef typename genericLattice1D<T>::pointer pointer; 00143 00144 /** 00145 * Const pointer to value_type 00146 */ 00147 typedef typename genericLattice1D<T>::const_pointer const_pointer; 00148 00149 /** 00150 * Reference to value_type 00151 */ 00152 typedef typename genericLattice1D<T>::reference reference; 00153 00154 /** 00155 * Const reference to value_type 00156 */ 00157 typedef typename genericLattice1D<T>::const_reference const_reference; 00158 00159 /** 00160 * \c iterator type (allows read and write operations). 00161 * 00162 * The use of the iterator classes is similar to the iterators of the STL 00163 * (Standard Template Library). See cvr::genericLattice1D::begin() and 00164 * cvr::genericLattice1D::inverseBegin() for examples. 00165 * 00166 * For the debugging version of the iterators, boundary check will be 00167 * done! This explains the low speed of the iterators of the debug 00168 * version. In the release version, no boundary check will be done, 00169 * and the iterators are sometimes a factor 10 faster than the 00170 * debug iterators. 00171 * 00172 * The use of the access operator at() is faster than the iterators in the 00173 * debug version only. If you need to iterate on a genericLattice1D use 00174 * iterators instead (in the release version iterators are approximately a 00175 * factor 3 faster than at()). 00176 * 00177 * \warning Try to use the prefix incremental operator (i.e. ++it) instead 00178 * of the postfix operator (i.e. it++) to allow efficient code also in 00179 * debug-modus! 00180 * 00181 * @see genericLattice1D<T>::const_iterator 00182 */ 00183 typedef typename genericLattice1D<T>::iterator iterator; 00184 00185 /** 00186 * \c const_iterator type (allows read-only operations). 00187 * 00188 * The use of the iterator classes is similar to the iterators of the STL 00189 * (Standard Template Library). See cvr::genericLattice1D::begin() for an 00190 * example. 00191 * 00192 * For the debugging version of the iterators, boundary check will be 00193 * done! This explains the low speed of the iterators of the debug 00194 * version. In the release version, no boundary check will be done, and 00195 * the iterators are sometimes a factor 10 faster than the debug 00196 * iterators. 00197 * 00198 * The use of the access operator at() is faster than the iterators in the 00199 * debug version only. If you need to iterate on a genericLattice1D use 00200 * iterators instead (in the release version iterators are approximately a 00201 * factor 3 faster than at()). 00202 * 00203 * \warning Try to use the prefix incremental operator (i.e. ++it) instead 00204 * of the postfix operator (i.e. it++) to allow efficient code also in 00205 * debug-modus! 00206 * 00207 * @see genericLattice1D<T>::iterator 00208 */ 00209 typedef typename genericLattice1D<T>::const_iterator const_iterator; 00210 //@} 00211 00212 /** 00213 * Default constructor creates an empty lattice1D; 00214 */ 00215 lattice1D(); 00216 00217 /** 00218 * Create a lattice1D indexed by the given interval but do \b not 00219 * initialize its elements. 00220 * 00221 * @param from initial index. 00222 * @param to final index. 00223 * 00224 * The size of the container will be to-from+1. The \c to value must be 00225 * greater or equal than the \c from value, otherwise an empty lattice will 00226 * be created. 00227 */ 00228 explicit lattice1D(const size_type from,const size_type to); 00229 00230 /** 00231 * Create a lattice1D indexed by the given interval but do \b not 00232 * initialize its elements. 00233 * 00234 * @param indices interval of indices to be used. 00235 */ 00236 explicit lattice1D(const iinterval& indices); 00237 00238 /** 00239 * Create a lattice1D indexed by the given interval and initialize 00240 * it with the given value. 00241 * 00242 * @param from initial index value 00243 * @param to final index value 00244 * @param iniValue all elements will be initialized with this value. 00245 */ 00246 explicit lattice1D(const size_type from, 00247 const size_type to, 00248 const_reference iniValue); 00249 00250 /** 00251 * Create a lattice1D indexed by the given interval and initialize 00252 * it with the given value. 00253 * 00254 * @param indices index interval 00255 * @param iniValue all elements will be initialized with this value. 00256 */ 00257 explicit lattice1D(const iinterval& indices, 00258 const_reference iniValue); 00259 00260 /** 00261 * Create a lattice1D indexed by the given interval and initialize 00262 * it with the given data. The \a data will be copied. 00263 * 00264 * If you need to just use the memory block without copying it, then you 00265 * can wether use a third parameter of eConstantReference type or later 00266 * call the useExternData() method. 00267 * 00268 * @see useExternData() 00269 * 00270 * @param from initial index value 00271 * @param to final index value 00272 * @param data a pointer to the data that will be copied. 00273 */ 00274 lattice1D(const size_type from, 00275 const size_type to, 00276 const value_type data[]); 00277 00278 /** 00279 * Create a lattice1D indexed by the given interval and initialize 00280 * it with the given data. The \a data will be copied. 00281 * 00282 * If you need to just use the memory block without copying it, then you 00283 * can wether use a third parameter of eConstantReference type or later 00284 * call the useExternData() method. 00285 * 00286 * @see useExternData() 00287 * 00288 * @param indices index interval 00289 * @param data a pointer to the data that will be copied. 00290 */ 00291 lattice1D(const iinterval& indices, 00292 const value_type data[]); 00293 00294 /** 00295 * Create a lattice1D indexed by the given interval and initialize 00296 * it with the given data, the same way "useExternData" does, i.e. the 00297 * \a data will \b not be copied!. 00298 * 00299 * @see useExternData() 00300 * 00301 * @param from initial index 00302 * @param to final index 00303 * @param data a pointer to the data that will be used. 00304 * @param constRef if this parameter is \c ConstantReference it will not be 00305 * possible to change the pointer to the external memory 00306 * block nor to resize the lattice1D. Despite this, 00307 * the value of each element can be changed by the access 00308 * operators. 00309 */ 00310 lattice1D(const size_type from, 00311 const size_type to, 00312 value_type data[], 00313 const eConstantReference constRef); 00314 00315 /** 00316 * Create a lattice1D indexed by the given interval and initialize 00317 * it with the given data, the same way "useExternData" does, i.e. the 00318 * \a data will \b not be copied!. 00319 * 00320 * @see useExternData() 00321 * 00322 * @param indices interval used for the lattice indices 00323 * @param data a pointer to the data that will be used. 00324 * @param constRef if this parameter is \c ConstantReference it will not be 00325 * possible to change the pointer to the external memory 00326 * block nor to resize the lattice1D. Despite this, 00327 * the value of each element can be changed by the access 00328 * operators. 00329 */ 00330 lattice1D(const iinterval& indices, 00331 value_type data[], 00332 const eConstantReference constRef); 00333 00334 /** 00335 * Create this lattice1D as a copy of another lattice1D 00336 * @param other the lattice1D to be copied. 00337 */ 00338 lattice1D(const genericLattice1D<T>& other); 00339 00340 /** 00341 * Create this lattice1D as a copy of the specified interval of 00342 * elements of another lattice1D. The \c from and \c to values are 00343 * truncated to the interval used by the \c other lattice. 00344 * 00345 * @param other the lattice1D to be copied. 00346 * @param from starting index of \c other lattice. 00347 * @param to end index of the \c other lattice. 00348 */ 00349 lattice1D(const genericLattice1D<T>& other, 00350 const size_type from, 00351 const size_type to=container::MaxIndex); 00352 00353 /** 00354 * Create this lattice1D as a copy of the specified interval of 00355 * elements of another lattice1D. The \c from and \c to values are 00356 * truncated to the interval used by the \c other lattice. 00357 * 00358 * @param other the lattice1D to be copied. 00359 * @param indices index interval of the elements of \c other to be copied. 00360 */ 00361 lattice1D(const genericLattice1D<T>& other, 00362 const iinterval& indices); 00363 00364 00365 /** 00366 * Create this lattice1D as a copy of another std::vector<T> 00367 * 00368 * @param other the lattice1D to be copied. 00369 * @param firstIndex index used for the first element of the vector. 00370 */ 00371 lattice1D(const std::vector<T>& other,const int firstIndex=0); 00372 00373 /** 00374 * Create this lattice1D as a copy of another cvr::genericVector. 00375 * 00376 * @param other the lattice1D to be copied. 00377 * @param firstIndex optional argument indicating which index is 00378 * going to be assigned to the first vector element. 00379 */ 00380 lattice1D(const genericVector<T>& other,const int firstIndex=0); 00381 00382 /** 00383 * Destructor 00384 */ 00385 virtual ~lattice1D(); 00386 00387 /** 00388 * Returns the name of this class. 00389 */ 00390 const std::string& name() const; 00391 00392 /** 00393 * Create a clone of this lattice1D. 00394 * 00395 * @return a pointer to a copy of this lattice1D 00396 */ 00397 virtual lattice1D<T>* clone() const; 00398 00399 /** 00400 * Create a new lattice1D instance. 00401 * 00402 * @return a pointer to a new instance of lattice1D 00403 */ 00404 virtual lattice1D<T>* newInstance() const; 00405 00406 /** 00407 * Compare this lattice1D with \c other, and use the given tolerance to 00408 * determine if the value of each element of the other lattice1D 00409 * approximately equals the values of the actual lattice1D elements. 00410 * 00411 * An element \a x is approximately equal to another element \a y 00412 * with a tolerance \a t, if following equation holds: 00413 * \a x-t < \a y < \a x+t. 00414 * 00415 * Both lattices must have exactly the same definition interval. Otherwise 00416 * \c false is returned. 00417 * 00418 * @param other the other lattice1D to be compared with 00419 * @param tolerance the tolerance to be used 00420 * 00421 * @return true if both lattice1Ds are approximatly equal 00422 */ 00423 bool prettyCloseTo(const genericLattice1D<T>& other, 00424 const T& tolerance) const; 00425 00426 /** 00427 * @name Arithmetical Operations 00428 */ 00429 //@{ 00430 /** 00431 * Dot product with another lattice1D of the \e same type. 00432 * 00433 * The dot product of lattices is here defined as the sum of the products 00434 * of elements sharing the same indices. If the lattices have different 00435 * definition intervals, then only the common interval will be considered 00436 * (as it will be assumed that the other lattice has a zero in all other 00437 * undefined elements. 00438 * 00439 * @param other the other lattice1D to be multiplied with 00440 * @return a scalar value with the type of the lattice1D elements 00441 */ 00442 T dot(const genericLattice1D<T>& other) const; 00443 00444 /** 00445 * Elementwise multiplication. 00446 * 00447 * Each element of this lattice1D will be multiplied with the corresponding 00448 * elements of the other lattice1D and the result will be left in this 00449 * %object! 00450 * 00451 * If both lattice1Ds have different definition intervals, an assertion 00452 * will be thrown. 00453 * 00454 * @param other the other lattice1D to be multiplied with 00455 * @return a reference to the actual lattice1D 00456 */ 00457 lattice1D<T>& emultiply(const genericLattice1D<T>& other); 00458 00459 /** 00460 * Elementwise multiplication. 00461 * 00462 * This lattice1D will contain the elementwise multiplication of the 00463 * elements in \a first and \a second. 00464 * 00465 * If both lattice1Ds have different definition intervals, an assertion 00466 * will be thrown. 00467 * 00468 * @param first the first lattice1D 00469 * @param second the second lattice1D will be multiplied with the 00470 * first lattice1D 00471 * @return a reference to the actual lattice1D 00472 */ 00473 lattice1D<T>& emultiply(const genericLattice1D<T>& first, 00474 const genericLattice1D<T>& second); 00475 00476 /** 00477 * Elementwise division. 00478 * 00479 * Each element of this lattice1D will be divided by the elements 00480 * of the other lattice1D and the result will be left in this %object! 00481 * The returned lattice1D is this %object! 00482 * 00483 * If both lattice1Ds have different definition intervals, an assertion 00484 * will be thrown. 00485 * 00486 * @param other the other lattice1D to be divided by 00487 * @return a reference to the actual lattice1D 00488 */ 00489 lattice1D<T>& edivide(const genericLattice1D<T>& other); 00490 00491 /** 00492 * Elementwise division. 00493 * 00494 * This lattice1D will contain the elementwise division of the 00495 * elements in \a first by \a second. 00496 * 00497 * If both lattice1Ds have different definition intervals, an assertion 00498 * will be thrown 00499 * 00500 * @param first the first lattice1D 00501 * @param second the second lattice1D, is the divisor 00502 * @return a reference to the actual lattice1D 00503 */ 00504 lattice1D<T>& edivide(const genericLattice1D<T>& first, 00505 const genericLattice1D<T>& second); 00506 00507 /** 00508 * Divide this lattice1D with a constant. This lattice1D will be changed! 00509 * Returns this lattice1D. 00510 * synonym for divide(const T cst). 00511 * @param cst the elements of the lattice1D will be divided with this 00512 * constant 00513 * @return a reference to the actual lattice1D 00514 */ 00515 inline lattice1D<T>& edivide(const T cst); 00516 00517 /** 00518 * Divide the other lattice1D with a constant and leave the result here. 00519 * Returns a reference to this lattice1D. <p> 00520 * synonym for divide(const lattice1D<T>& other,const T cst). 00521 * @param other the lattice1D to be divide by the constant value 00522 * @param cst the elements of the lattice1D will be divided with this 00523 * constant 00524 * @return a reference to the actual lattice1D 00525 */ 00526 inline lattice1D<T>& edivide(const genericLattice1D<T>& other,const T cst); 00527 00528 /** 00529 * Add another lattice1D of the same type and same dimension and 00530 * leave the result in this %object. 00531 * If both lattice1Ds have different size, an assertion will be thrown 00532 * @param other the other lattice1D to be added with 00533 * @return a reference to the actual lattice1D 00534 */ 00535 lattice1D<T>& add(const genericLattice1D<T>& other); 00536 00537 /** 00538 * Add two lattice1D and leave the result in this %object. 00539 * If both lattice1Ds have different size, an assertion will be thrown 00540 * @param first the first lattice1D 00541 * @param second the second lattice1D will be added with the first 00542 * lattice1D 00543 * @return a reference to the actual lattice1D 00544 */ 00545 lattice1D<T>& add(const genericLattice1D<T>& first, 00546 const genericLattice1D<T>& second); 00547 00548 /** 00549 * Add constant to this lattice1D. This lattice1D is changed. 00550 * Returns this lattice1D. 00551 * @param cst constant scalar to be added with each element 00552 * @return a reference to the actual lattice1D 00553 */ 00554 lattice1D<T>& add(const T cst); 00555 00556 /** 00557 * Add constant to the other lattice1D and leave the result here. 00558 * Returns a reference to this lattice1D. 00559 * @param other the other lattice1D 00560 * @param cst constant scalar to be added with each element of the other 00561 * lattice1D 00562 * @return a reference to the actual lattice1D 00563 */ 00564 lattice1D<T>& add(const genericLattice1D<T>& other,const T cst); 00565 00566 /** 00567 * Alias for add(const T cst) 00568 */ 00569 inline lattice1D<T>& operator+=(const T cst); 00570 00571 /** 00572 * Alias for add(const lattice1D<T>& other) 00573 */ 00574 inline lattice1D<T>& operator+=(const genericLattice1D<T>& other); 00575 00576 /** 00577 * Add another lattice1D scaled by \e b to this lattice1D. The lattice1Ds 00578 * must be of the same types and dimensions. Let \e A be this lattice1D 00579 * and \e B the other lattice1D, then this method performs:<p> 00580 * \f$A=A+b\cdot B\f$ 00581 * If both lattice1Ds have different size, an assertion will be thrown 00582 * @param b scaling factor for \a other 00583 * @param other the lattice1D to be added after scaling 00584 * @return a reference to this lattice1D 00585 */ 00586 lattice1D<T>& addScaled(const T b, const genericLattice1D<T>& other); 00587 00588 /** 00589 * Leave the scaled %sum of two lattice1Ds in this lattice1D. The lattice1Ds 00590 * must be of the same types and dimensions. Let \e A be the 00591 * first lattice1D and \e B the second lattice1D with corresponding 00592 * scaling factors \e a and \e b, further \e C this 00593 * lattice1D, then this method performs:<p> 00594 * \f$C=a\cdot A+b\cdot B\f$ 00595 * If both lattice1Ds have different size, an assertion will be thrown 00596 * @param a scaling factor for \a first 00597 * @param first the first lattice1D to be added after scaling 00598 * @param b scaling factor for \a second 00599 * @param second the second lattice1D to be added after scaling 00600 * @return a reference to this lattice1D 00601 */ 00602 lattice1D<T>& addScaled(const T a, const genericLattice1D<T>& first, 00603 const T b, const genericLattice1D<T>& second); 00604 00605 00606 /** 00607 * Leave the addition of the first lattice1D and the second lattice1D 00608 * scaled with the given factor in this lattice1D. The lattice1Ds must 00609 * be of the same types and dimensions. Let \e A be the first 00610 * lattice1D and \e B the second lattice1D with corresponding scaling 00611 * factor \e b, further \e C this lattice1D, then this method 00612 * performs:<p> \f$C=A+b\cdot B\f$ 00613 * If both lattice1Ds have different size, an assertion will be thrown 00614 * @param first the first lattice1D to be added after scaling 00615 * @param b scaling factor for \a second 00616 * @param second the second lattice1D to be added after scaling 00617 * @return a reference to this lattice1D 00618 */ 00619 lattice1D<T>& addScaled(const genericLattice1D<T>& first, 00620 const T b, 00621 const genericLattice1D<T>& second); 00622 00623 /** 00624 * Subtract constant from this lattice1D. This lattice1D is changed. 00625 * Returns this lattice1D. 00626 * @param cst constant scalar to be subtracted from each element 00627 * @return a reference to the actual lattice1D 00628 */ 00629 lattice1D<T>& subtract(const T cst); 00630 00631 /** 00632 * Subtract constant from the other lattice1D and leave the result here. 00633 * Returns a reference to this lattice1D. 00634 * @param other the other lattice1D 00635 * @param cst constant scalar to be subtracted from each element of the 00636 * other lattice1D 00637 * @return a reference to the actual lattice1D 00638 */ 00639 lattice1D<T>& subtract(const genericLattice1D<T>& other, const T cst); 00640 00641 /** 00642 * Subtracts another lattice1D of the same type and same dimension 00643 * and leaves the result in this %object 00644 * If both lattice1Ds have different size, an assertion will be thrown 00645 * @param other will be substracted from this lattice1D 00646 * @return a reference to the actual lattice1D 00647 */ 00648 lattice1D<T>& subtract(const genericLattice1D<T>& other); 00649 00650 /** 00651 * Subtracts two lattice1Ds and leaves the result in this %object. 00652 * If both lattice1Ds have different size, an assertion will be thrown 00653 * @param first the first lattice1D 00654 * @param second the second lattice1D will be substracted from the 00655 * first lattice1D 00656 * @return a reference to the actual lattice1D 00657 */ 00658 lattice1D<T>& subtract(const genericLattice1D<T>& first, 00659 const genericLattice1D<T>& second); 00660 00661 /** 00662 * Alias for substract(const lattice1D<T>& other) 00663 * If both lattice1Ds have different size, an assertion will be thrown 00664 */ 00665 inline lattice1D<T>& operator-=(const genericLattice1D<T>& other); 00666 00667 /** 00668 * Alias for subtract(const T& cst) 00669 */ 00670 lattice1D<T>& operator-=(const T cst); 00671 00672 /** 00673 * Multiply this lattice1D with a constant. This lattice1D will changed! 00674 * Returns this lattice1D. 00675 * If both lattice1Ds have different size, an assertion will be thrown 00676 * @param cst constant scalar to be multiplied with 00677 * @return a reference to the actual lattice1D 00678 */ 00679 lattice1D<T>& multiply(const T cst); 00680 00681 /** 00682 * Multiply the other %lattice1D with a constant and leave the result here. 00683 * Returns a reference to this lattice1D. 00684 * If both lattice1Ds have different size, an assertion will be thrown 00685 * @param other the other lattice1D to be multiplied with the constant value 00686 * @param cst constant scalar to be multiplied with the other lattice1D. 00687 * @return a reference to the actual lattice1D 00688 */ 00689 lattice1D<T>& multiply(const genericLattice1D<T>& other,const T cst); 00690 00691 /** 00692 * Multiply with a constant. This lattice1D is changed. 00693 * @param cst constant scalar to be multiplied with 00694 * @return a reference to the actual lattice1D 00695 */ 00696 lattice1D<T>& operator*=(const T cst); 00697 00698 /** 00699 * Divide this lattice1D by a constant. This lattice1D will changed! 00700 * Returns this lattice1D. 00701 * @param cst the elements of the lattice1D will be divided with this 00702 * constant 00703 * @return a reference to the actual lattice1D 00704 */ 00705 lattice1D<T>& divide(const T cst); 00706 00707 /** 00708 * Divide the other lattice1D by a constant and leave the result here. 00709 * Returns a reference to this lattice1D. 00710 * @param other the lattice1D to be divide by the constant value 00711 * @param cst the elements of the lattice1D will be divided with this 00712 * constant 00713 * @return a reference to the actual lattice1D 00714 */ 00715 lattice1D<T>& divide(const genericLattice1D<T>& other,const T cst); 00716 00717 /** 00718 * Alias for divide(const T& cst) 00719 */ 00720 lattice1D<T>& operator/=(const T cst); 00721 00722 /** 00723 * Calculate the sum of all elements of the lattice1D. 00724 * This member can be used with classes which define the operator '+=' 00725 */ 00726 T computeSumOfElements() const; 00727 00728 /** 00729 * Calculate the product of all elements of the lattice1D. 00730 * This member can be used with classes which define the operator '*=' 00731 */ 00732 T computeProductOfElements() const; 00733 //@} 00734 00735 00736 /** 00737 * @name Find extreme values 00738 */ 00739 //@{ 00740 00741 /** 00742 * Find the smallest element of the lattice1D 00743 */ 00744 T findMinimum() const; 00745 00746 /** 00747 * Find the index of the smallest element of the lattice1D 00748 */ 00749 int findIndexOfMinimum() const; 00750 00751 /** 00752 * Find the biggest element of the lattice1D 00753 */ 00754 T findMaximum() const; 00755 00756 /** 00757 * Find the index of the biggest element of the lattice1D 00758 */ 00759 int findIndexOfMaximum() const; 00760 00761 /** 00762 * Find the extremes of the lattice1D (smallest and biggest elements) 00763 */ 00764 void findExtremes(T& theMinimum, T& theMaximum) const; 00765 00766 /** 00767 * Find the indices of the extremes of the lattice1D 00768 * (smallest and biggest elements) 00769 */ 00770 void findIndexOfExtremes(int& theIdxMinimum, int& theIdxMaximum) const; 00771 //@} 00772 }; 00773 00774 } // namespace cvr 00775 00776 #include "cvrLattice1D_inline.h" 00777 00778 namespace cvr { 00779 /** 00780 * Lattice1D of double 00781 */ 00782 typedef lattice1D<double> dlattice1D; 00783 00784 /** 00785 * Lattice1D of float 00786 */ 00787 typedef lattice1D<float> flattice1D; 00788 00789 /** 00790 * Lattice1D of integer 00791 */ 00792 typedef lattice1D<int32> ilattice1D; 00793 00794 } 00795 00796 #endif