Main Page   Class Hierarchy   Compound List   File List   Compound Members  

matrix_hpoint.cpp

00001 /*=============================================================================
00002         File: matrix.cpp
00003      Purpose:       
00004     Revision: $Id: matrix_hpoint.cpp,v 1.2 2002/05/13 21:07:45 philosophil Exp $
00005   Created by: Philippe Lavoie          (3 Oct, 1996)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1998 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 
00026 #include "matrix.cpp"
00027 
00028 namespace PLib {
00029 
00030   double
00031     Matrix<HPoint3Df>::norm(void) {
00032     int i,j ;
00033     double sumX, sumY, sumZ, sumW, maxsum;
00034     int init=0 ;
00035     HPoint3Df *ptr ;
00036     ptr = m-1 ;
00037     maxsum = -1 ; // shuts up the warning messages 
00038     for(i=0;i<rows();++i){
00039       sumX = 0.0 ;
00040       sumY = 0.0 ;
00041       sumZ = 0.0 ;
00042       sumW = 0.0 ;
00043       for ( j = 0; j < cols(); ++j) {
00044         sumX += (*ptr).x() * (*ptr).x() ;
00045         sumY += (*ptr).y() * (*ptr).y() ;
00046         sumZ += (*ptr).z() * (*ptr).z() ;
00047         sumW += (*ptr).w() * (*ptr).w() ;
00048       }
00049       if(init)
00050         maxsum = (maxsum>(sumX+sumY+sumZ+sumW)) ? maxsum : (sumX+sumY+sumZ+sumW);
00051       else{
00052         maxsum = (sumX+sumY+sumZ+sumW) ;
00053         init = 1;
00054       }
00055       ++ptr ;
00056     }
00057     return sqrt(maxsum);
00058   }
00059   
00060   
00061   double
00062     Matrix<HPoint3Dd>::norm(void) {
00063     int i,j ;
00064     double sumX, sumY, sumZ, sumW, maxsum;
00065     int init=0 ;
00066     HPoint3Dd *ptr ;
00067     ptr = m-1 ;
00068     maxsum = -1 ; // shuts up the warning messages 
00069     for(i=0;i<rows();++i){
00070       sumX = 0.0 ;
00071       sumY = 0.0 ;
00072       sumZ = 0.0 ;
00073       sumW = 0.0 ;
00074       for ( j = 0; j < cols(); ++j) {
00075         sumX += (*ptr).x() * (*ptr).x() ;
00076         sumY += (*ptr).y() * (*ptr).y() ;
00077         sumZ += (*ptr).z() * (*ptr).z() ;
00078         sumW += (*ptr).w() * (*ptr).w() ;
00079       }
00080       if(init)
00081         maxsum = (maxsum>(sumX+sumY+sumZ+sumW)) ? maxsum : (sumX+sumY+sumZ+sumW);
00082       else{
00083         maxsum = (sumX+sumY+sumZ+sumW) ;
00084         init = 1;
00085       }
00086       ++ptr ;
00087     }
00088     return sqrt(maxsum);
00089   }
00090   
00091   
00092   double
00093     Matrix<HPoint2Df>::norm(void) {
00094     int i,j ;
00095     double sumX, sumY, sumZ, sumW, maxsum;
00096     int init=0 ;
00097     HPoint2Df *ptr ;
00098     ptr = m-1 ;
00099     maxsum = -1 ; // shuts up the warning messages 
00100     for(i=0;i<rows();++i){
00101       sumX = 0.0 ;
00102       sumY = 0.0 ;
00103       sumZ = 0.0 ;
00104       sumW = 0.0 ;
00105       for ( j = 0; j < cols(); ++j) {
00106         sumX += (*ptr).x() * (*ptr).x() ;
00107         sumY += (*ptr).y() * (*ptr).y() ;
00108         sumZ += (*ptr).z() * (*ptr).z() ;
00109         sumW += (*ptr).w() * (*ptr).w() ;
00110       }
00111       if(init)
00112         maxsum = (maxsum>(sumX+sumY+sumZ+sumW)) ? maxsum : (sumX+sumY+sumZ+sumW);
00113       else{
00114         maxsum = (sumX+sumY+sumZ+sumW) ;
00115         init = 1;
00116       }
00117       ++ptr ;
00118     }
00119     return sqrt(maxsum);
00120   }
00121   
00122   double
00123     Matrix<HPoint2Dd>::norm(void) {
00124     int i,j ;
00125     double sumX, sumY, sumZ, sumW, maxsum;
00126     int init=0 ;
00127     HPoint2Dd *ptr ;
00128     ptr = m-1 ;
00129     maxsum = -1 ; // shuts up the warning messages 
00130     for(i=0;i<rows();++i){
00131       sumX = 0.0 ;
00132       sumY = 0.0 ;
00133       sumZ = 0.0 ;
00134       sumW = 0.0 ;
00135       for ( j = 0; j < cols(); ++j) {
00136         sumX += (*ptr).x() * (*ptr).x() ;
00137         sumY += (*ptr).y() * (*ptr).y() ;
00138         sumZ += (*ptr).z() * (*ptr).z() ;
00139         sumW += (*ptr).w() * (*ptr).w() ;
00140       }
00141       if(init)
00142         maxsum = (maxsum>(sumX+sumY+sumZ+sumW)) ? maxsum : (sumX+sumY+sumZ+sumW);
00143       else{
00144         maxsum = (sumX+sumY+sumZ+sumW) ;
00145         init = 1;
00146       }
00147       ++ptr ;
00148     }
00149     return sqrt(maxsum);
00150   }
00151   
00152   
00153 
00154 #ifdef NO_IMPLICIT_TEMPLATES
00155 
00156   // HPoint3D instantiation
00157   
00158   template class Matrix<HPoint3Df> ;
00159   
00160   template Matrix<HPoint3Df> operator+(const Matrix<HPoint3Df>&,const Matrix<HPoint3Df>&);
00161   template Matrix<HPoint3Df> operator-(const Matrix<HPoint3Df>&,const Matrix<HPoint3Df>&);
00162   template Matrix<HPoint3Df> operator*(const Matrix<HPoint3Df>&,const Matrix<HPoint3Df>&);
00163   template Matrix<HPoint3Df> operator*(const double,const Matrix<HPoint3Df>&);
00164   template int operator==(const Matrix<HPoint3Df>&,const Matrix<HPoint3Df>&);
00165   // template int operator!=(const Matrix<HPoint3Df>&,const Matrix<HPoint3Df>&);
00166   template Matrix<HPoint3Df> comm(const Matrix<HPoint3Df>&,const Matrix<HPoint3Df>&);
00167   
00168   
00169   template class Matrix<HPoint3Dd> ;
00170 
00171   template Matrix<HPoint3Dd> operator+(const Matrix<HPoint3Dd>&,const Matrix<HPoint3Dd>&);
00172   template Matrix<HPoint3Dd> operator-(const Matrix<HPoint3Dd>&,const Matrix<HPoint3Dd>&);
00173   template Matrix<HPoint3Dd> operator*(const Matrix<HPoint3Dd>&,const Matrix<HPoint3Dd>&);
00174   template Matrix<HPoint3Dd> operator*(const double,const Matrix<HPoint3Dd>&);
00175   template int operator==(const Matrix<HPoint3Dd>&,const Matrix<HPoint3Dd>&);
00176   //template int operator!=(const Matrix<HPoint3Dd>&,const Matrix<HPoint3Dd>&);
00177   template Matrix<HPoint3Dd> comm(const Matrix<HPoint3Dd>&,const Matrix<HPoint3Dd>&);
00178   
00179   
00180   // HPoint2D instantiation
00181   
00182   template class Matrix<HPoint2Df> ;
00183   
00184   template Matrix<HPoint2Df> operator+(const Matrix<HPoint2Df>&,const Matrix<HPoint2Df>&);
00185   template Matrix<HPoint2Df> operator-(const Matrix<HPoint2Df>&,const Matrix<HPoint2Df>&);
00186   template Matrix<HPoint2Df> operator*(const Matrix<HPoint2Df>&,const Matrix<HPoint2Df>&);
00187   template Matrix<HPoint2Df> operator*(const double,const Matrix<HPoint2Df>&);
00188   template int operator==(const Matrix<HPoint2Df>&,const Matrix<HPoint2Df>&);
00189   //template int operator!=(const Matrix<HPoint2Df>&,const Matrix<HPoint2Df>&);
00190   template Matrix<HPoint2Df> comm(const Matrix<HPoint2Df>&,const Matrix<HPoint2Df>&);
00191   
00192   
00193   template class Matrix<HPoint2Dd> ;
00194   
00195   template Matrix<HPoint2Dd> operator+(const Matrix<HPoint2Dd>&,const Matrix<HPoint2Dd>&);
00196   template Matrix<HPoint2Dd> operator-(const Matrix<HPoint2Dd>&,const Matrix<HPoint2Dd>&);
00197   template Matrix<HPoint2Dd> operator*(const Matrix<HPoint2Dd>&,const Matrix<HPoint2Dd>&);
00198   template Matrix<HPoint2Dd> operator*(const double,const Matrix<HPoint2Dd>&);
00199   template int operator==(const Matrix<HPoint2Dd>&,const Matrix<HPoint2Dd>&);
00200   //template int operator!=(const Matrix<HPoint2Dd>&,const Matrix<HPoint2Dd>&);
00201   template Matrix<HPoint2Dd> comm(const Matrix<HPoint2Dd>&,const Matrix<HPoint2Dd>&);
00202   
00203 #endif
00204 
00205 }

Generated on Tue Jun 24 13:26:55 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002