9 #include <QtCore/qmath.h>
67 if (storedMatrixData.
name() !=
"CorrelationMatrixData") {
68 QString msg =
"This Pvl Object does not have the correct correlation information. The Object "
69 "you are looking for is called CorrelationMatrixData.";
74 m_covarianceFileName =
78 QString msg =
"Could not find the Covariance Matrix .dat file name.";
83 QString corrFileName = storedMatrixData.
findKeyword(
"CorrelationMatrixFileName")[0];
84 if (corrFileName ==
"NULL") {
92 QString msg =
"Could not find the Correlation Matrix .dat file name.";
98 imgsIt = storedMatrixData.
findGroup(
"ImagesAndParameters").begin();
99 while ( imgsIt != storedMatrixData.
findGroup(
"ImagesAndParameters").end() ) {
106 QString msg =
"Could not get Images and Parameters from ImagesAndParameters group.";
157 if (&other !=
this) {
164 m_covarianceFileName = NULL;
176 m_visibleBlocks = NULL;
197 QString msg =
"Cannot compute correlation matrix without a specified file name. Use "
198 "setCorrelationFileName(FileName) before calling computeCorrelationMatrix().";
210 matrixInput.open(QIODevice::ReadOnly);
211 matrixOutput.open(QIODevice::WriteOnly);
214 QDataStream inStream(&matrixInput);
215 QDataStream outStream(&matrixOutput);
217 double firstParam1 = 0,
223 while ( !inStream.atEnd() ) {
227 int numOfBlocks = sbcm.size();
228 int lastBlock = numOfBlocks - 1;
229 int numDiagonals = sbcm[lastBlock]->size1();
232 for (
int i = 0; i < numDiagonals; i++) {
233 double val = ( *(sbcm[lastBlock]) )(i, i);
238 QMapIterator<int, LinearAlgebra::Matrix *> block(sbcm);
240 while ( block.hasNext() ) {
242 for (
int row = 0; row < (int)block.value()->size1(); row++) {
243 for (
int column = 0; column < (int)block.value()->size2(); column++) {
245 ( *block.value() )(row, column) = ( *block.value() )(row, column) /
251 param2 = firstParam2;
253 firstParam1 += block.value()->size1();
254 param1 = firstParam1;
257 param1 = firstParam1;
258 firstParam2 += block.value()->size2();
259 param2 = firstParam2;
267 matrixOutput.close();
357 QString fName = covarianceFileName.expanded().replace( QString(
"inverse"),
358 QString(
"correlation") );
465 PvlObject corrMatInfo(
"CorrelationMatrixData");
470 PvlGroup imgsAndParams(
"ImagesAndParameters");
472 while ( imgParamIt.hasNext() ) {
474 imgsAndParams +=
PvlKeyword( imgParamIt.key(), imgParamIt.value().join(
",") );
476 corrMatInfo += imgsAndParams;
551 return matrix.
write(stream);
562 return matrix.
read(stream);
QMap< QString, QStringList > * m_imagesAndParameters
This map holds the images used to create this matrix and their associated parameters.
QList< SparseBlockColumnMatrix > * m_visibleBlocks
This will be the three blocks (or whole matrix depending on size) that apply to the given area...
void retrieveVisibleElements(int x, int y)
This method will open the correlation matrix file and read in the blocks that apply to the requested ...
void retrieveWholeMatrix()
This method will read the matrix in from the file and hold on to the whole thing. ...
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
This is a container for the correlation matrix that comes from a bundle adjust.
FileName covarianceFileName()
Public access for the covariance matrix file name.
File name manipulation and expansion.
CorrelationMatrix()
Default Constructor.
void setCorrelationFileName(FileName correlationFileName)
Set the qmap of images and parameters.
FileName correlationFileName()
Public access for the correlation matrix file name.
void computeCorrelationMatrix()
This method reads the covariance matrix in from a file, one SparseBlockColumnMatrix at a time...
void setImagesAndParameters(QMap< QString, QStringList > imagesAndParameters)
Set the qmap of images and parameters.
~CorrelationMatrix()
Destructor.
QDataStream & read(QDataStream &stream)
Reads CorrelationMatrix data from the input stream and places the data in member variables.
This error is for when a programmer made an API call that was illegal.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
PvlObject pvlObject()
This method creates a Pvl group with the information necessary to recreate this correlation matrix...
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
void retrieveThreeVisibleBlocks()
This method will be used when the matrix is too big to display the whole thing.
QList< double > * m_diagonals
List of the parameter values.
A type of error that could only have occurred due to a mistake on the user's part (e...
A single keyword-value pair.
bool hasCovMat()
This is used to make sure the covariance matrix exists.
void setCovarianceFileName(FileName covarianceFileName)
Set the qmap of images and parameters.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
FileName * m_correlationFileName
FileName of the correlation matrix.
FileName * m_covarianceFileName
FileName of the covariance matrix calculated when the bundle was run.
bool isValid()
This is the public accessor for the list of elements that should be displayed in the current view...
QList< SparseBlockColumnMatrix > * visibleBlocks()
Get the visible part of the matrix.
CorrelationMatrix & operator=(const CorrelationMatrix &other)
Equal Operator.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Contains Pvl Groups and Pvl Objects.
QString name() const
Returns the container name.
QDataStream & write(QDataStream &stream) const
Writes CorrelationMatrix data to the output stream and returns this stream to the user...
QMap< QString, QStringList > * imagesAndParameters()
Public access for the qmap of images and parameters.
QList< PvlKeyword >::iterator PvlKeywordIterator
The keyword iterator.