00001 /************************************************************************* 00002 00003 Copyright Rice University, 2004. 00004 All rights reserved. 00005 00006 Permission is hereby granted, free of charge, to any person obtaining a 00007 copy of this software and associated documentation files (the "Software"), 00008 to deal in the Software without restriction, including without limitation 00009 the rights to use, copy, modify, merge, publish, distribute, and/or sell 00010 copies of the Software, and to permit persons to whom the Software is 00011 furnished to do so, provided that the above copyright notice(s) and this 00012 permission notice appear in all copies of the Software and that both the 00013 above copyright notice(s) and this permission notice appear in supporting 00014 documentation. 00015 00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY 00019 RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS 00020 NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL 00021 DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 00022 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 00023 ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 00024 THIS SOFTWARE. 00025 00026 Except as contained in this notice, the name of a copyright holder shall 00027 not be used in advertising or otherwise to promote the sale, use or other 00028 dealings in this Software without prior written authorization of the 00029 copyright holder. 00030 00031 **************************************************************************/ 00032 00033 #ifndef __HCL2RN 00034 #define __HCL2RN 00035 00036 #include "functions.hh" 00037 #include "rn.hh" 00038 #include "localspace.hh" 00039 #include "locallinalg.hh" 00040 00041 namespace RVL { 00042 00047 template<class Scalar> 00048 class RnSpace: public LocalSpace<Scalar> { 00049 private: 00050 00051 int dim; 00052 RnDataContainerFactory<Scalar> * dcfac; 00053 RVLLinearAlgebraPackage<Scalar> lap; 00054 RVLLinearAlgebraPackage<Scalar> & lapref; 00055 00056 protected: 00057 00058 void redim(int newdim) { 00059 try { 00060 dim = newdim; 00061 if (dcfac) delete dcfac; 00062 dcfac = new RnDataContainerFactory<Scalar>(dim); 00063 } 00064 catch (RVLException & e) { 00065 e<<"\ncalled from RnSpace::redim\n"; 00066 throw e; 00067 } 00068 } 00069 00070 Space<Scalar> * clone() const { return new RnSpace<Scalar>(*this); } 00071 00072 LocalDataContainerFactory<Scalar> & getLDCF() const { return *dcfac; } 00073 LinearAlgebraPackage<Scalar> & getLAP() const { return lapref; } 00074 00075 public: 00076 00077 RnSpace(int n=0): dim(n), lap(), lapref(lap) { 00078 try { 00079 dcfac = new RnDataContainerFactory<Scalar>(dim); 00080 } 00081 catch (RVLException & e) { 00082 e<<"\ncalled from RnSpace constructor\n"; 00083 throw e; 00084 } 00085 } 00086 RnSpace(const RnSpace<Scalar> & sp): dim(sp.dim), lap(), lapref(lap) { 00087 try { 00088 dcfac = new RnDataContainerFactory<Scalar>(dim); 00089 } 00090 catch (RVLException & e) { 00091 e<<"\ncalled from RnSpace constructor\n"; 00092 throw e; 00093 } 00094 } 00095 00096 bool isCompatible(DataContainer const & dc) const { 00097 try { 00098 return getLDCF().isCompatible(dc); 00099 } 00100 catch (RVLException & e) { 00101 e<<"\ncalled from RnSpace::isCompatible\n"; 00102 throw e; 00103 } 00104 } 00105 00106 virtual ~RnSpace() { 00107 if (dcfac) delete dcfac; 00108 } 00109 00110 int getSize() const { return dim; } 00111 00112 virtual void write(RVLException & str) const { 00113 str<<"RnSpace: simple dense vector space\n"; 00114 str<<"dimension = "<<dim<<"\n"; 00115 } 00116 virtual ostream & write(ostream & str) const { 00117 str<<"RnSpace: simple dense vector space\n"; 00118 str<<"dimension = "<<dim<<"\n"; 00119 return str; 00120 } 00121 }; 00122 00123 } 00124 00125 #endif 00126 00127 00128 00129 00130 00131 00132