Main Page   Class Hierarchy   Compound List   File List   Compound Members  

vector_complex.cpp

00001 /*=============================================================================
00002         File: vector.cpp
00003      Purpose:
00004     Revision: $Id: vector_complex.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 "vector.cpp"
00027 
00028 namespace PLib {
00029 
00030   template<>
00031     Vector<Complex>  operator*(const Vector<Complex>& v, const double d)
00032     {
00033       int i, sz = v.size();
00034       Vector<Complex> b(v.size());
00035       
00036       Complex *aptr,*bptr ;
00037       aptr = v.x-1 ;
00038       bptr = b.x-1 ;
00039       for (i = sz; i > 0; --i){
00040         *(++bptr) = (Complex)(d * (*(++aptr)) ) ;
00041       }
00042       
00043       return b;
00044       
00045     }
00046   
00047   template <>
00048     Vector<Complex>  operator*(const Vector<Complex>& v, 
00049                                const Complex d)
00050     {
00051       int i, sz = v.size();
00052       Vector<Complex> b = v;
00053       
00054       Complex *bptr=b.x ;
00055       for (i = sz; i > 0; --i)
00056         *(++bptr) *= d;
00057       
00058       return b;
00059       
00060     }
00061   
00062   template <>
00063     int Vector<Complex>::minIndex() const {
00064     Complex min = x[0] ;
00065     int index = 0 ;
00066     
00067     Complex *p ;
00068     p = x-1 ;
00069     
00070     for(int i=1;i<n();i++){
00071       if(abs(*(++p))<abs(min)){
00072         min = *p ;
00073         index = i ;
00074       }
00075     }
00076     return index ;
00077   }
00078 
00079   template <>
00080     void Vector<Complex>::qSort(int){
00081 #ifdef USE_EXCEPTION
00082     throw MatrixErr() ;
00083 #else
00084     Error error("Vector<Complex>::qSort()");
00085     error << "Sorry! The complex quick sort operator isn't working.\n" ;
00086     error.fatal() ;
00087 #endif
00088   }
00089   
00090   template <>
00091     void Vector<Complex>::sortIndex(Vector<int>&, int) const {
00092 #ifdef USE_EXCEPTION
00093     throw MatrixErr() ;
00094 #else
00095     Error error("Vector<Complex>::sortIndex()");
00096     error << "Sorry! The complex quick sort operator isn't working.\n" ;
00097     error.fatal() ;
00098 #endif
00099   }
00100   
00101   
00102 #ifdef NO_IMPLICIT_TEMPLATES
00103   
00104   template class Vector<Complex> ;
00105   
00106   template Vector<Complex> operator+(const Vector<Complex>&, const Vector<Complex>&);
00107   template Vector<Complex> operator-(const Vector<Complex>&, const Vector<Complex>&);
00108   template Complex operator*(const Vector<Complex>&,const Vector<Complex>&);
00109   template int operator==(const Vector<Complex>&,const Vector<Complex>&);
00110   template int operator!=(const Vector<Complex>&,const Vector<Complex>&);
00111 
00112 #endif
00113 
00114 }

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