DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_matrix.hGo to the documentation of this file.00001 /*****************************************************************************/ 00002 // Copyright 2006-2008 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/workarea/stern/camera_raw/dng_sdk/source/dng_matrix.h#7 $ */ 00010 /* $DateTime: 2008/01/21 03:56:54 $ */ 00011 /* $Change: 413512 $ */ 00012 /* $Author: stern $ */ 00013 00019 /*****************************************************************************/ 00020 00021 #ifndef __dng_matrix__ 00022 #define __dng_matrix__ 00023 00024 /*****************************************************************************/ 00025 00026 #include "dng_sdk_limits.h" 00027 #include "dng_types.h" 00028 00029 /*****************************************************************************/ 00030 00031 class dng_matrix 00032 { 00033 00034 protected: 00035 00036 uint32 fRows; 00037 uint32 fCols; 00038 00039 real64 fData [kMaxColorPlanes] [kMaxColorPlanes]; 00040 00041 public: 00042 00043 dng_matrix (); 00044 00045 dng_matrix (uint32 rows, 00046 uint32 cols); 00047 00048 dng_matrix (const dng_matrix &m); 00049 00050 virtual ~dng_matrix () 00051 { 00052 } 00053 00054 void Clear (); 00055 00056 void SetIdentity (uint32 count); 00057 00058 uint32 Rows () const 00059 { 00060 return fRows; 00061 } 00062 00063 uint32 Cols () const 00064 { 00065 return fCols; 00066 } 00067 00068 real64 * operator [] (uint32 row) 00069 { 00070 return fData [row]; 00071 } 00072 00073 const real64 * operator [] (uint32 row) const 00074 { 00075 return fData [row]; 00076 } 00077 00078 bool operator== (const dng_matrix &m) const; 00079 00080 bool operator!= (const dng_matrix &m) const 00081 { 00082 return !(*this == m); 00083 } 00084 00085 bool IsEmpty () const 00086 { 00087 return fRows == 0 || fCols == 0; 00088 } 00089 00090 bool NotEmpty () const 00091 { 00092 return !IsEmpty (); 00093 } 00094 00095 bool IsDiagonal () const; 00096 00097 real64 MaxEntry () const; 00098 00099 real64 MinEntry () const; 00100 00101 void Scale (real64 factor); 00102 00103 void Round (real64 factor); 00104 00105 void SafeRound (real64 factor); 00106 00107 }; 00108 00109 /*****************************************************************************/ 00110 00111 class dng_matrix_3by3: public dng_matrix 00112 { 00113 00114 public: 00115 00116 dng_matrix_3by3 (); 00117 00118 dng_matrix_3by3 (const dng_matrix &m); 00119 00120 dng_matrix_3by3 (real64 a00, real64 a01, real64 a02, 00121 real64 a10, real64 a11, real64 a12, 00122 real64 a20, real64 a21, real64 a22); 00123 00124 dng_matrix_3by3 (real64 a00, real64 a11, real64 a22); 00125 00126 }; 00127 00128 /*****************************************************************************/ 00129 00130 class dng_matrix_4by3: public dng_matrix 00131 { 00132 00133 public: 00134 00135 dng_matrix_4by3 (); 00136 00137 dng_matrix_4by3 (const dng_matrix &m); 00138 00139 dng_matrix_4by3 (real64 a00, real64 a01, real64 a02, 00140 real64 a10, real64 a11, real64 a12, 00141 real64 a20, real64 a21, real64 a22, 00142 real64 a30, real64 a31, real64 a32); 00143 00144 }; 00145 00146 /*****************************************************************************/ 00147 00148 class dng_vector 00149 { 00150 00151 protected: 00152 00153 uint32 fCount; 00154 00155 real64 fData [kMaxColorPlanes]; 00156 00157 public: 00158 00159 dng_vector (); 00160 00161 dng_vector (uint32 count); 00162 00163 dng_vector (const dng_vector &v); 00164 00165 virtual ~dng_vector () 00166 { 00167 } 00168 00169 void Clear (); 00170 00171 void SetIdentity (uint32 count); 00172 00173 uint32 Count () const 00174 { 00175 return fCount; 00176 } 00177 00178 real64 & operator [] (uint32 index) 00179 { 00180 return fData [index]; 00181 } 00182 00183 const real64 & operator [] (uint32 index) const 00184 { 00185 return fData [index]; 00186 } 00187 00188 bool operator== (const dng_vector &v) const; 00189 00190 bool operator!= (const dng_vector &v) const 00191 { 00192 return !(*this == v); 00193 } 00194 00195 bool IsEmpty () const 00196 { 00197 return fCount == 0; 00198 } 00199 00200 bool NotEmpty () const 00201 { 00202 return !IsEmpty (); 00203 } 00204 00205 real64 MaxEntry () const; 00206 00207 real64 MinEntry () const; 00208 00209 void Scale (real64 factor); 00210 00211 void Round (real64 factor); 00212 00213 dng_matrix AsDiagonal () const; 00214 00215 dng_matrix AsColumn () const; 00216 00217 }; 00218 00219 /*****************************************************************************/ 00220 00221 class dng_vector_3: public dng_vector 00222 { 00223 00224 public: 00225 00226 dng_vector_3 (); 00227 00228 dng_vector_3 (const dng_vector &v); 00229 00230 dng_vector_3 (real64 a0, 00231 real64 a1, 00232 real64 a2); 00233 00234 }; 00235 00236 /*****************************************************************************/ 00237 00238 dng_matrix operator* (const dng_matrix &A, 00239 const dng_matrix &B); 00240 00241 dng_vector operator* (const dng_matrix &A, 00242 const dng_vector &B); 00243 00244 dng_matrix operator* (real64 scale, 00245 const dng_matrix &A); 00246 00247 dng_vector operator* (real64 scale, 00248 const dng_vector &A); 00249 00250 /*****************************************************************************/ 00251 00252 dng_matrix operator+ (const dng_matrix &A, 00253 const dng_matrix &B); 00254 00255 /*****************************************************************************/ 00256 00257 dng_matrix Transpose (const dng_matrix &A); 00258 00259 /*****************************************************************************/ 00260 00261 dng_matrix Invert (const dng_matrix &A); 00262 00263 dng_matrix Invert (const dng_matrix &A, 00264 const dng_matrix &hint); 00265 00266 /*****************************************************************************/ 00267 00268 inline real64 MaxEntry (const dng_matrix &A) 00269 { 00270 return A.MaxEntry (); 00271 } 00272 00273 inline real64 MaxEntry (const dng_vector &A) 00274 { 00275 return A.MaxEntry (); 00276 } 00277 00278 /*****************************************************************************/ 00279 00280 inline real64 MinEntry (const dng_matrix &A) 00281 { 00282 return A.MinEntry (); 00283 } 00284 00285 inline real64 MinEntry (const dng_vector &A) 00286 { 00287 return A.MinEntry (); 00288 } 00289 00290 /*****************************************************************************/ 00291 00292 #endif 00293 00294 /*****************************************************************************/ |