Main Page   Class Hierarchy   Compound List   File List   Compound Members  

matrix_point.cpp

00001 /*=============================================================================
00002         File: matrix.cpp
00003      Purpose:       
00004     Revision: $Id: matrix_point.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<Point3Df>::norm(void) {
00032     int i,j ;
00033     double sumX, sumY, sumZ, maxsum;
00034     int init=0 ;
00035     Point3Df *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       for ( j = 0; j < cols(); ++j) {
00043         sumX += (*ptr).x() * (*ptr).x() ;
00044         sumY += (*ptr).y() * (*ptr).y() ;
00045         sumZ += (*ptr).z() * (*ptr).z() ;
00046       }
00047       if(init)
00048         maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
00049       else{
00050         maxsum = (sumX+sumY+sumZ) ;
00051         init = 1;
00052       }
00053       ++ptr ;
00054     }
00055     return sqrt(maxsum);
00056   }
00057   
00058   double
00059     Matrix<Point3Dd>::norm(void) {
00060     int i,j ;
00061     double sumX, sumY, sumZ, maxsum;
00062     int init=0 ;
00063     Point3Dd *ptr ;
00064     ptr = m-1 ;
00065     maxsum = -1 ; // shuts up the warning messages 
00066     for(i=0;i<rows();++i){
00067       sumX = 0.0 ;
00068       sumY = 0.0 ;
00069       sumZ = 0.0 ;
00070       for ( j = 0; j < cols(); ++j) {
00071         sumX += (*ptr).x() * (*ptr).x() ;
00072         sumY += (*ptr).y() * (*ptr).y() ;
00073         sumZ += (*ptr).z() * (*ptr).z() ;
00074       }
00075       if(init)
00076         maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
00077       else{
00078         maxsum = (sumX+sumY+sumZ) ;
00079         init = 1;
00080       }
00081       ++ptr ;
00082     }
00083     return sqrt(maxsum);
00084   }
00085   
00086   double
00087     Matrix<Point2Df>::norm(void) {
00088     int i,j ;
00089     double sumX, sumY, sumZ, maxsum;
00090     int init=0 ;
00091     Point2Df *ptr ;
00092     ptr = m-1 ;
00093     maxsum = -1 ; // shuts up the warning messages 
00094     for(i=0;i<rows();++i){
00095       sumX = 0.0 ;
00096       sumY = 0.0 ;
00097       sumZ = 0.0 ;
00098       for ( j = 0; j < cols(); ++j) {
00099         sumX += (*ptr).x() * (*ptr).x() ;
00100         sumY += (*ptr).y() * (*ptr).y() ;
00101         sumZ += (*ptr).z() * (*ptr).z() ;
00102       }
00103       if(init)
00104         maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
00105       else{
00106         maxsum = (sumX+sumY+sumZ) ;
00107         init = 1;
00108       }
00109       ++ptr ;
00110     }
00111     return sqrt(maxsum);
00112   }
00113 
00114   double
00115     Matrix<Point2Dd>::norm(void) {
00116     int i,j ;
00117     double sumX, sumY, sumZ, maxsum;
00118     int init=0 ;
00119     Point2Dd *ptr ;
00120     ptr = m-1 ;
00121     maxsum = -1 ; // shuts up the warning messages 
00122     for(i=0;i<rows();++i){
00123       sumX = 0.0 ;
00124       sumY = 0.0 ;
00125       sumZ = 0.0 ;
00126       for ( j = 0; j < cols(); ++j) {
00127         sumX += (*ptr).x() * (*ptr).x() ;
00128         sumY += (*ptr).y() * (*ptr).y() ;
00129         sumZ += (*ptr).z() * (*ptr).z() ;
00130       }
00131       if(init)
00132         maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
00133       else{
00134         maxsum = (sumX+sumY+sumZ) ;
00135         init = 1;
00136       }
00137       ++ptr ;
00138     }
00139     return sqrt(maxsum);
00140   }
00141   
00142 
00143 #ifdef NO_IMPLICIT_TEMPLATES
00144 
00145   // Point3D instantiation
00146   
00147   template class Matrix<Point3Df> ;
00148   
00149   template Matrix<Point3Df> operator+(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
00150   template Matrix<Point3Df> operator-(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
00151   template Matrix<Point3Df> operator*(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
00152   template Matrix<Point3Df> operator*(const double,const Matrix<Point3Df>&);
00153   template int operator==(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
00154   // template int operator!=(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
00155   template Matrix<Point3Df> comm(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
00156   
00157   
00158   template class Matrix<Point3Dd> ;
00159   
00160   template Matrix<Point3Dd> operator+(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
00161   template Matrix<Point3Dd> operator-(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
00162   template Matrix<Point3Dd> operator*(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
00163   template Matrix<Point3Dd> operator*(const double,const Matrix<Point3Dd>&);
00164   template int operator==(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
00165   //template int operator!=(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
00166   template Matrix<Point3Dd> comm(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
00167   
00168   // Point2D instantiation
00169   
00170   template class Matrix<Point2Df> ;
00171   
00172   template Matrix<Point2Df> operator+(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
00173   template Matrix<Point2Df> operator-(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
00174   template Matrix<Point2Df> operator*(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
00175   template Matrix<Point2Df> operator*(const double,const Matrix<Point2Df>&);
00176   template int operator==(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
00177   //template int operator!=(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
00178   template Matrix<Point2Df> comm(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
00179   
00180 
00181   template class Matrix<Point2Dd> ;
00182   
00183   template Matrix<Point2Dd> operator+(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
00184   template Matrix<Point2Dd> operator-(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
00185   template Matrix<Point2Dd> operator*(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
00186   template Matrix<Point2Dd> operator*(const double,const Matrix<Point2Dd>&);
00187   template int operator==(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
00188   //template int operator!=(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
00189   template Matrix<Point2Dd> comm(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
00190 
00191 #endif
00192 
00193 }

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