FineKernelToolKit
2.8.10
|
00001 /**************************************************************************** 00002 * 00003 * Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, 00006 * with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 00009 * - Redistributions of source code must retain the above 00010 * copyright notice, this list of conditions and the 00011 * following disclaimer. 00012 * 00013 * - Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the 00015 * following disclaimer in the documentation and/or 00016 * other materials provided with the distribution. 00017 * 00018 * - Neither the name of the copyright holders nor the names 00019 * of its contributors may be used to endorse or promote 00020 * products derived from this software without specific 00021 * prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00029 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00031 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00032 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00033 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************/ 00037 /**************************************************************************** 00038 * 00039 * Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved. 00040 * 00041 * 本ソフトウェアおよびソースコードのライセンスは、基本的に 00042 * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。 00043 * 00044 * ソースコード形式かバイナリ形式か、変更するかしないかを問わず、 00045 * 以下の条件を満たす場合に限り、再頒布および使用が許可されます。 00046 * 00047 * - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、 00048 * および下記免責条項を含めること。 00049 * 00050 * - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の 00051 * 資料に、上記の著作権表示、本条件一覧、および下記免責条項を 00052 * 含めること。 00053 * 00054 * - 書面による特別の許可なしに、本ソフトウェアから派生した製品の 00055 * 宣伝または販売促進に、本ソフトウェアの著作権者の名前または 00056 * コントリビューターの名前を使用してはならない。 00057 * 00058 * 本ソフトウェアは、著作権者およびコントリビューターによって「現 00059 * 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、 00060 * および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ 00061 * に限定されない、いかなる保証もないものとします。著作権者もコン 00062 * トリビューターも、事由のいかんを問わず、損害発生の原因いかんを 00063 * 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その 00064 * 他の)不法行為であるかを問わず、仮にそのような損害が発生する可 00065 * 能性を知らされていたとしても、本ソフトウェアの使用によって発生 00066 * した(代替品または代用サービスの調達、使用の喪失、データの喪失、 00067 * 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、 00068 * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に 00069 * ついて、一切責任を負わないものとします。 00070 * 00071 ****************************************************************************/ 00072 #ifndef __FK_GEN_VECTOR_HEADER__ 00073 #define __FK_GEN_VECTOR_HEADER__ 00074 00075 #include <FK/Vector.h> 00076 00077 class fk_GenMatrix; 00078 00080 00090 class fk_GenVector { 00091 00092 friend class fk_GenMatrix; 00093 00094 private: 00095 00096 std::vector<double> v; 00097 00098 public: 00099 00101 00108 fk_GenVector(int deg = 0); 00109 00111 00116 fk_GenVector(std::vector<double> &array); 00117 00119 00125 fk_GenVector(int deg, double *array); 00126 00128 fk_GenVector(const fk_GenVector &); 00129 00131 fk_GenVector(const fk_Vector &); 00132 00134 fk_GenVector(const fk_HVector &); 00135 00137 //@( 00138 00140 00149 fk_GenVector & operator -(void) const; 00150 00151 //@) 00152 00154 //@( 00155 00157 00171 bool operator ==(const fk_GenVector &) const; 00172 00174 00188 bool operator !=(const fk_GenVector &) const; 00189 00190 //@) 00191 00193 //@( 00194 00196 fk_GenVector & operator =(const fk_GenVector &); 00197 00199 fk_GenVector & operator =(const fk_Vector &); 00200 00202 fk_GenVector & operator =(const fk_HVector &); 00203 00205 00219 fk_GenVector & operator *=(double d); 00220 00222 00238 fk_GenVector & operator /=(double); 00239 00241 00257 fk_GenVector & operator +=(const fk_GenVector &); 00258 00260 00276 fk_GenVector & operator -=(const fk_GenVector &); 00277 00279 00295 fk_GenVector & operator *=(const fk_GenMatrix &); 00296 00297 //@) 00298 00300 //@( 00301 00303 00308 void resize(int deg); 00309 00310 // 成分値設定関数 00319 bool set(int ID, double value); 00320 00322 00326 int size(void) const; 00327 00329 00335 double get(int ID) const; // 値取得 00336 00338 00349 double norm(void) const; 00350 00352 00363 double norm2(void) const; 00364 00366 00380 bool normalize(void); 00381 00383 00388 void init(bool degFlg = false); 00389 00391 00396 bool isZero(void) const; 00397 00399 00421 bool replace(int s, fk_GenVector &Q); 00422 00424 00446 bool replace(int s, fk_Vector &Q); 00447 00449 00471 bool replace(int s, fk_HVector &Q); 00472 00474 00496 bool add(int s, fk_GenVector &Q); 00497 00499 00521 bool add(int s, fk_Vector &Q); 00522 00524 00546 bool add(int s, fk_HVector &Q); 00547 00549 00571 bool sub(int s, fk_GenVector &Q); 00572 00574 00596 bool sub(int s, fk_Vector &Q); 00597 00599 00621 bool sub(int s, fk_HVector &Q); 00622 00624 00633 fk_GenVector div(int s, int e); 00634 00635 #ifndef FK_DOXYGEN_USER_PROCESS 00636 00637 void Print(void) const; 00638 void Print(std::string) const; 00639 00640 #endif 00641 00643 //@( 00644 friend double operator *(const fk_GenVector &, const fk_GenVector &); 00645 friend fk_GenVector operator +(const fk_GenVector &, const fk_GenVector &); 00646 friend fk_GenVector operator -(const fk_GenVector &, const fk_GenVector &); 00647 friend fk_GenVector operator *(const fk_GenVector &, double); 00648 friend fk_GenVector operator *(double, const fk_GenVector &); 00649 friend fk_GenVector operator /(const fk_GenVector &, double); 00650 friend fk_GenVector operator ^(const fk_GenVector &, const fk_GenVector &); 00651 //@) 00652 }; 00653 00655 00657 00675 double operator *(const fk_GenVector &P, const fk_GenVector &Q); 00676 00678 00689 fk_GenVector operator +(const fk_GenVector &P, const fk_GenVector &Q); 00690 00692 00703 fk_GenVector operator -(const fk_GenVector &P, const fk_GenVector &Q); 00704 00706 00716 fk_GenVector operator *(const fk_GenVector &V, double d); 00717 00719 00729 fk_GenVector operator *(double d, const fk_GenVector &V); 00730 00732 00740 fk_GenVector operator /(const fk_GenVector &V, double d); 00741 00742 00744 00765 fk_GenVector operator ^(const fk_GenVector &P, const fk_GenVector &Q); 00766 00767 #endif // !__FK_GEN_VECTOR_HEADER__