Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
matrix_point.cpp
Package: nurbs++-3.0.11.zip [view]
Upload User: ysz425
Upload Date: 2008-03-14
Package Size: 675k
Code Size: 6k
Category:
Linux-Unix program
Development Platform:
Unix_Linux
- /*=============================================================================
- File: matrix.cpp
- Purpose:
- Revision: $Id: matrix_point.cpp,v 1.2 2002/05/13 21:07:45 philosophil Exp $
- Created by: Philippe Lavoie (3 Oct, 1996)
- Modified by:
- Copyright notice:
- Copyright (C) 1996-1998 Philippe Lavoie
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- =============================================================================*/
- #include "matrix.cpp"
- namespace PLib {
- double
- Matrix<Point3Df>::norm(void) {
- int i,j ;
- double sumX, sumY, sumZ, maxsum;
- int init=0 ;
- Point3Df *ptr ;
- ptr = m-1 ;
- maxsum = -1 ; // shuts up the warning messages
- for(i=0;i<rows();++i){
- sumX = 0.0 ;
- sumY = 0.0 ;
- sumZ = 0.0 ;
- for ( j = 0; j < cols(); ++j) {
- sumX += (*ptr).x() * (*ptr).x() ;
- sumY += (*ptr).y() * (*ptr).y() ;
- sumZ += (*ptr).z() * (*ptr).z() ;
- }
- if(init)
- maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
- else{
- maxsum = (sumX+sumY+sumZ) ;
- init = 1;
- }
- ++ptr ;
- }
- return sqrt(maxsum);
- }
- double
- Matrix<Point3Dd>::norm(void) {
- int i,j ;
- double sumX, sumY, sumZ, maxsum;
- int init=0 ;
- Point3Dd *ptr ;
- ptr = m-1 ;
- maxsum = -1 ; // shuts up the warning messages
- for(i=0;i<rows();++i){
- sumX = 0.0 ;
- sumY = 0.0 ;
- sumZ = 0.0 ;
- for ( j = 0; j < cols(); ++j) {
- sumX += (*ptr).x() * (*ptr).x() ;
- sumY += (*ptr).y() * (*ptr).y() ;
- sumZ += (*ptr).z() * (*ptr).z() ;
- }
- if(init)
- maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
- else{
- maxsum = (sumX+sumY+sumZ) ;
- init = 1;
- }
- ++ptr ;
- }
- return sqrt(maxsum);
- }
- double
- Matrix<Point2Df>::norm(void) {
- int i,j ;
- double sumX, sumY, sumZ, maxsum;
- int init=0 ;
- Point2Df *ptr ;
- ptr = m-1 ;
- maxsum = -1 ; // shuts up the warning messages
- for(i=0;i<rows();++i){
- sumX = 0.0 ;
- sumY = 0.0 ;
- sumZ = 0.0 ;
- for ( j = 0; j < cols(); ++j) {
- sumX += (*ptr).x() * (*ptr).x() ;
- sumY += (*ptr).y() * (*ptr).y() ;
- sumZ += (*ptr).z() * (*ptr).z() ;
- }
- if(init)
- maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
- else{
- maxsum = (sumX+sumY+sumZ) ;
- init = 1;
- }
- ++ptr ;
- }
- return sqrt(maxsum);
- }
- double
- Matrix<Point2Dd>::norm(void) {
- int i,j ;
- double sumX, sumY, sumZ, maxsum;
- int init=0 ;
- Point2Dd *ptr ;
- ptr = m-1 ;
- maxsum = -1 ; // shuts up the warning messages
- for(i=0;i<rows();++i){
- sumX = 0.0 ;
- sumY = 0.0 ;
- sumZ = 0.0 ;
- for ( j = 0; j < cols(); ++j) {
- sumX += (*ptr).x() * (*ptr).x() ;
- sumY += (*ptr).y() * (*ptr).y() ;
- sumZ += (*ptr).z() * (*ptr).z() ;
- }
- if(init)
- maxsum = (maxsum>(sumX+sumY+sumZ)) ? maxsum : (sumX+sumY+sumZ);
- else{
- maxsum = (sumX+sumY+sumZ) ;
- init = 1;
- }
- ++ptr ;
- }
- return sqrt(maxsum);
- }
- #ifdef NO_IMPLICIT_TEMPLATES
- // Point3D instantiation
- template class Matrix<Point3Df> ;
- template Matrix<Point3Df> operator+(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
- template Matrix<Point3Df> operator-(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
- template Matrix<Point3Df> operator*(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
- template Matrix<Point3Df> operator*(const double,const Matrix<Point3Df>&);
- template int operator==(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
- // template int operator!=(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
- template Matrix<Point3Df> comm(const Matrix<Point3Df>&,const Matrix<Point3Df>&);
- template class Matrix<Point3Dd> ;
- template Matrix<Point3Dd> operator+(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
- template Matrix<Point3Dd> operator-(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
- template Matrix<Point3Dd> operator*(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
- template Matrix<Point3Dd> operator*(const double,const Matrix<Point3Dd>&);
- template int operator==(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
- //template int operator!=(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
- template Matrix<Point3Dd> comm(const Matrix<Point3Dd>&,const Matrix<Point3Dd>&);
- // Point2D instantiation
- template class Matrix<Point2Df> ;
- template Matrix<Point2Df> operator+(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
- template Matrix<Point2Df> operator-(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
- template Matrix<Point2Df> operator*(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
- template Matrix<Point2Df> operator*(const double,const Matrix<Point2Df>&);
- template int operator==(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
- //template int operator!=(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
- template Matrix<Point2Df> comm(const Matrix<Point2Df>&,const Matrix<Point2Df>&);
- template class Matrix<Point2Dd> ;
- template Matrix<Point2Dd> operator+(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
- template Matrix<Point2Dd> operator-(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
- template Matrix<Point2Dd> operator*(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
- template Matrix<Point2Dd> operator*(const double,const Matrix<Point2Dd>&);
- template int operator==(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
- //template int operator!=(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
- template Matrix<Point2Dd> comm(const Matrix<Point2Dd>&,const Matrix<Point2Dd>&);
- #endif
- }