diff --git a/Code/Mantid/Framework/CurveFitting/test/FitMWTest.h b/Code/Mantid/Framework/CurveFitting/test/FitMWTest.h index 10df2d6e82dfb54122ffbf65c3721a7832e210f5..dc1038edc784878eec6d68a2fa8935dfcc27ae7d 100644 --- a/Code/Mantid/Framework/CurveFitting/test/FitMWTest.h +++ b/Code/Mantid/Framework/CurveFitting/test/FitMWTest.h @@ -361,21 +361,14 @@ public: } -#ifdef _WIN32 -#pragma warning( push ) -// Disable division by 0 warning -#pragma warning( disable: 4723 ) -#endif - void test_ignore_invalid_data() { auto ws = createTestWorkspace(false); - const double zero = 0.0; const double one = 1.0; - ws->dataY(0)[3] = 1.0 / zero; + ws->dataY(0)[3] = std::numeric_limits<double>::infinity(); ws->dataY(0)[5] = log(-one); ws->dataE(0)[7] = 0; - ws->dataE(0)[9] = 1.0 / zero; + ws->dataE(0)[9] = std::numeric_limits<double>::infinity(); ws->dataE(0)[11] = log(-one); FunctionDomain_sptr domain; @@ -445,10 +438,6 @@ public: } -#ifdef _WIN32 -#pragma warning ( pop ) // Re-enable the warning -#endif - private: API::MatrixWorkspace_sptr createTestWorkspace(const bool histogram) diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h index 5b3b22f762407bf4952cf660f9145e5554ed07ca..f6d3bd8c7d0dceab9a83e14839e5ddacd0ca6f68 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h @@ -19,7 +19,9 @@ namespace Mantid namespace MDEvents { +#ifndef __INTEL_COMPILER // As of July 13, the packing has no effect for the Intel compiler and produces a warning #pragma pack(push, 4) //Ensure the structure is no larger than it needs to +#endif //=============================================================================================== /** Templated class for a multi-dimensional event "box". @@ -183,7 +185,9 @@ namespace MDEvents }; +#ifndef __INTEL_COMPILER #pragma pack(pop) //Return to default packing size +#endif //------------------------------------------------------------------------------------------------------------------------------------------------------------ /* Internal TMP class to simplify adding events to the box for events and lean events using single interface*/ diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxBase.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxBase.h index 3eb057f6857556bebd1c740d5e778981dff9e637..3990d4062f47f650591bfdfafc3240023bb30ae6 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxBase.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxBase.h @@ -1,18 +1,17 @@ #ifndef MDBOXBASE_H_ #define MDBOXBASE_H_ -#include "MantidAPI/IMDWorkspace.h" #include "MantidAPI/IMDNode.h" +#include <iosfwd> +#include "MantidMDEvents/MDBin.h" +#include "MantidMDEvents/MDLeanEvent.h" +#include "MantidAPI/BoxController.h" +#include "MantidAPI/IMDWorkspace.h" +#include "MantidAPI/CoordTransform.h" #include "MantidGeometry/MDGeometry/MDDimensionExtents.h" #include "MantidGeometry/MDGeometry/MDImplicitFunction.h" #include "MantidKernel/ISaveable.h" #include "MantidKernel/System.h" -#include "MantidAPI/BoxController.h" -//#include "MantidMDEvents/BoxCtrlChangesList.h" -#include "MantidAPI/CoordTransform.h" -#include "MantidMDEvents/MDBin.h" -#include "MantidMDEvents/MDLeanEvent.h" -#include <iosfwd> #include "MantidKernel/VMD.h" @@ -24,7 +23,9 @@ namespace Mantid namespace MDEvents { +#ifndef __INTEL_COMPILER // As of July 13, the packing has no effect for the Intel compiler and produces a warning #pragma pack(push, 4) //Ensure the structure is no larger than it needs to +#endif //=============================================================================================== /** Templated super-class of a multi-dimensional event "box". @@ -68,7 +69,7 @@ namespace MDEvents /// sets the special id, which specify the position of this node in the chain linearly ordered nodes virtual void setID(const size_t &newID){m_fileID = newID;} // -------------------------------- Parents/Children-Related ------------------------------------------- - /// Return a pointer to the parent box + /// Return a pointer to the parent box void setParent(IMDNode * parent) { m_parent = parent; } @@ -85,13 +86,13 @@ namespace MDEvents { return this; } // -------------------------------- Events-Related ------------------------------------------- - /** The method to convert events in a box into a table of coodrinates/signal/errors casted into coord_t type + /** The method to convert events in a box into a table of coodrinates/signal/errors casted into coord_t type * Used to conver events into plain data array. Does nothing for GridBox */ - virtual void getEventsData(std::vector<coord_t> &/*coordTable*/,size_t &/*nColumns*/)const{}; + virtual void getEventsData(std::vector<coord_t> &/*coordTable*/,size_t &/*nColumns*/) const {} /** The method to convert the table of data into vector of events * Used to convert from a vector of values (2D table in Fortran representation (by rows) into box events. Does nothing for GridBox (may be temporary) -- can be combined with build and add events */ - virtual void setEventsData(const std::vector<coord_t> &/*coordTable*/){}; + virtual void setEventsData(const std::vector<coord_t> &/*coordTable*/) {} /// Return a copy of contained events virtual std::vector< MDE > * getEventsCopy() = 0; @@ -193,7 +194,7 @@ namespace MDEvents return mess; } - /** For testing: return the internal-stored size of each box in each dimension */ + /** For testing: return the internal-stored size of each box in each dimension */ coord_t getBoxSize(size_t d) { return extents[d].getSize(); @@ -357,12 +358,12 @@ namespace MDEvents * Set when refreshCache() is called. */ mutable signal_t m_totalWeight; - /// Inverse of the volume of the cell, to be used for normalized signal. - coord_t m_inverseVolume; - /// The box splitting controller, shared with all boxes in the hierarchy Mantid::API::BoxController * const m_BoxController; + /// Inverse of the volume of the cell, to be used for normalized signal. + coord_t m_inverseVolume; + /// Recursion depth uint32_t m_depth; @@ -372,23 +373,22 @@ namespace MDEvents /// The id which specify location of this box in a linear chain of ordered boxes (e.g. on file). Calculated algorithmically size_t m_fileID; /// Mutex for modifying the event list or box averages - Mantid::Kernel::Mutex m_dataMutex; + Mantid::Kernel::Mutex m_dataMutex; + private: - MDBoxBase(const MDBoxBase<MDE,nd> & box); + MDBoxBase(const MDBoxBase<MDE,nd> & box); + public: /// Convenience typedef for a shared pointer to a this type of class typedef boost::shared_ptr< MDBoxBase<MDE, nd> > sptr; }; //(end class MDBoxBase) +#ifndef __INTEL_COMPILER #pragma pack(pop) //Return to default packing size - - - - +#endif }//namespace MDEvents - }//namespace Mantid #endif /* MDBOXBASE_H_ */ diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h index 3198f1cd7169f88b44d548e4df4b24650fb07ca1..1bf6575c58c71c2485bbd9092cb4b3aa2f394b38 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h @@ -17,7 +17,9 @@ namespace Mantid namespace MDEvents { +#ifndef __INTEL_COMPILER // As of July 13, the packing has no effect for the Intel compiler and produces a warning #pragma pack(push, 4) //Ensure the structure is no larger than it needs to +#endif //=============================================================================================== /** Templated class for a GRIDDED multi-dimensional event "box". @@ -58,13 +60,13 @@ namespace MDEvents virtual void setFileBacked(); virtual void clearFileBacked(bool loadDiskBackedData); void clear(); - void clearDataFromMemory(){/*it seems works on boxes only though recursive clearing makes sence, not yet implemented*/}; + void clearDataFromMemory(){/*it seems works on boxes only though recursive clearing makes sence, not yet implemented*/} /**Save the box at specific disk position using the class, respoinsible for the file IO. */ - virtual void saveAt(API::IBoxControllerIO *const /* */, uint64_t /*position*/)const - {/*Not saveable */}; + virtual void saveAt(API::IBoxControllerIO *const /* */, uint64_t /*position*/) const + {/*Not saveable */} /**Load the box data of specified size from the disk location provided using the class, respoinsible for the file IO. */ virtual void loadAndAddFrom(API::IBoxControllerIO *const /* */, uint64_t /*position*/, size_t /* Size */) - {/*Not directly loadable */}; + {/*Not directly loadable */} //------------------------------------------------------------------------------------------------------- /** Uses the cached value of points stored in the grid box @@ -112,7 +114,7 @@ namespace MDEvents void centerpointBin(MDBin<MDE,nd> & bin, bool * fullyContained) const; - void generalBin(MDBin<MDE,nd> & /*bin*/, Mantid::Geometry::MDImplicitFunction & /*function*/) const {}; + void generalBin(MDBin<MDE,nd> & /*bin*/, Mantid::Geometry::MDImplicitFunction & /*function*/) const {} void integrateSphere(Mantid::API::CoordTransform & radiusTransform, const coord_t radiusSquared, signal_t & signal, signal_t & errorSquared) const; @@ -121,19 +123,11 @@ namespace MDEvents void integrateCylinder(Mantid::API::CoordTransform & radiusTransform, const coord_t radius, const coord_t length, signal_t & signal, signal_t & errorSquared, std::vector<signal_t> & signal_fit) const; void splitContents(size_t index, Kernel::ThreadScheduler * ts = NULL); - //void splitContentsById(size_t childId); // No definition causes a myriad of warnings on MSVC void splitAllIfNeeded(Kernel::ThreadScheduler * ts = NULL); - //void cacheChildrenToDisk(); // No definition causes a myriad of warnings on MSVC - void refreshCache(Kernel::ThreadScheduler * ts = NULL); - //void refreshCentroid(Kernel::ThreadScheduler * ts = NULL); - - // Set the box controller overrriden. - //virtual void setBoxController(Mantid::API::BoxController *controller); - virtual bool getIsMasked() const; ///Setter for masking the box virtual void mask(); @@ -146,11 +140,12 @@ namespace MDEvents //------------------------------------------------------------------------- - /** The function used to satisfy IMDNode interface but the physical meaning is unclear */ - void calculateCentroid(coord_t * /*centroid*/) const - { + /** The function used to satisfy IMDNode interface but the physical meaning is unclear */ + void calculateCentroid(coord_t * /*centroid*/) const + { throw(std::runtime_error("This function should not be called on MDGridBox (as its meaning for MDbox is dubious too)")); - } + } + public: /// Typedef for a shared pointer to a MDGridBox typedef boost::shared_ptr< MDGridBox<MDE, nd> > sptr; @@ -158,7 +153,6 @@ namespace MDEvents /// Typedef for a vector of MDBoxBase pointers typedef std::vector<MDBoxBase<MDE, nd>*> boxVector_t; - private: /// Each dimension is split into this many equally-sized boxes size_t split[nd]; @@ -174,7 +168,7 @@ namespace MDEvents * to the nd-array. */ std::vector<MDBoxBase<MDE,nd> *> m_Children; - /** Length (squared) of the diagonal through every dimension = sum( boxSize[i]^2 ) + /** Length (squared) of the diagonal through every dimension = sum( boxSize[i]^2 ) * Used in some calculations like peak integration */ coord_t diagonalSquared; @@ -190,69 +184,16 @@ namespace MDEvents /**private default copy constructor as the only correct constructor is the one with box controller */ MDGridBox(const MDGridBox<MDE, nd> & box); /**Private constructor as it does not work without box controller */ - MDGridBox(){}; + MDGridBox() {} /// common part of MDGridBox contstructor; void initGridBox(); - public: - - ////=============================================================================================== - ////=============================================================================================== - ///** Task for adding events to a MDGridBox. */ - //class AddEventsTask : public Mantid::Kernel::Task - //{ - //public: - // /// Pointer to MDGridBox. - // MDBoxBase<MDE, nd> * box; - // /// Reference to the MD events that will be added - // const std::vector<MDE> & events; - // /// Where to start in vector - // size_t start_at; - // /// Where to stop in vector - // size_t stop_at; - // /// Progress report - // Mantid::Kernel::ProgressBase * prog; - - // /** Ctor - // * - // * @param box :: Pointer to MDGridBox - // * @param events :: Reference to the MD events that will be added - // * @param start_at :: Where to start in vector - // * @param stop_at :: Where to stop in vector - // * @param prog :: ProgressReporting - // * @return - // */ - // AddEventsTask(MDBoxBase<MDE, nd> * box, const std::vector<MDE> & events, - // const size_t start_at, const size_t stop_at, Mantid::Kernel::ProgressBase * prog) - // : Mantid::Kernel::Task(), - // box(box), events(events), start_at(start_at), stop_at(stop_at), prog(prog) - // { - // } - - // /// Add the events in the MDGridBox. - // void run() - // { - // box->addEvents(events); - // if (prog) - // { - // std::ostringstream out; - // out << "Adding events " << start_at; - // prog->report(out.str()); - // } - // } - //}; - - - }; - +#ifndef __INTEL_COMPILER #pragma pack(pop) //Return to default packing size - - - +#endif }//namespace MDEvents - }//namespace Mantid #endif /* MDGRIDBOX_H_ */ diff --git a/Code/Mantid/Framework/MDEvents/src/MDBoxBase.cpp b/Code/Mantid/Framework/MDEvents/src/MDBoxBase.cpp index e59f252bc52c8a2fa6732445f35f977188a0b115..2ca40e37c8d9e3e02538bdff97456079ecc85033 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDBoxBase.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDBoxBase.cpp @@ -19,8 +19,8 @@ namespace MDEvents TMDE( MDBoxBase)::MDBoxBase(Mantid::API::BoxController * const boxController,const uint32_t depth,const size_t boxID): m_signal(0.0), m_errorSquared(0.0), m_totalWeight(0.0), - m_inverseVolume(std::numeric_limits<coord_t>::quiet_NaN()), m_BoxController(boxController), + m_inverseVolume(std::numeric_limits<coord_t>::quiet_NaN()), m_depth(depth), m_parent(NULL), m_fileID(boxID) @@ -40,8 +40,8 @@ namespace MDEvents TMDE( MDBoxBase)::MDBoxBase(Mantid::API::BoxController *const boxController,const uint32_t depth,const size_t boxID,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector) : m_signal(0.0), m_errorSquared(0.0), m_totalWeight(0.0), - m_inverseVolume(UNDEF_COORDT), m_BoxController(boxController), + m_inverseVolume(UNDEF_COORDT), m_depth(depth), m_parent(NULL), m_fileID(boxID) @@ -71,8 +71,8 @@ namespace MDEvents TMDE( MDBoxBase)::MDBoxBase(const MDBoxBase<MDE,nd> & box,Mantid::API::BoxController * const otherBC): m_signal(box.m_signal), m_errorSquared(box.m_errorSquared), m_totalWeight(box.m_totalWeight), - m_inverseVolume(box.m_inverseVolume), m_BoxController(otherBC), + m_inverseVolume(box.m_inverseVolume), m_depth(box.m_depth), m_parent(box.m_parent), m_fileID(box.m_fileID) diff --git a/Code/Mantid/MantidPlot/src/Mantid/MantidMatrixFunction.cpp b/Code/Mantid/MantidPlot/src/Mantid/MantidMatrixFunction.cpp index a463fc866b30f7ba42c4cc3ba6fdb2a030f1fb34..ad88cdb22c49cb4aa5a93f2ef8ead6ae6f5428fd 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/MantidMatrixFunction.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/MantidMatrixFunction.cpp @@ -171,13 +171,12 @@ size_t MantidMatrixFunction::indexX(size_t row,double s)const size_t n = m_workspace->blocksize(); const Mantid::MantidVec& X = m_workspace->readX(row); - if (n == 0 || s < X[0] || s > X[n-1]) return -1; + if (n == 0 || s < X[0] || s > X[n-1]) return std::numeric_limits<size_t>::max(); size_t i = 0, j = n-1, k = n/2; - double ss; for(size_t it = 0; it < n; it++) { - ss = X[k]; + const double ss = X[k]; if (ss == s ) return k; if (abs(static_cast<int>(i) - static_cast<int>(j)) <2) { @@ -202,26 +201,25 @@ size_t MantidMatrixFunction::indexY(double s)const bool isNumeric = yAxis.isNumeric(); - if (n == 0) return -1; + if (n == 0) return std::numeric_limits<size_t>::max(); size_t i0 = 0; if (s < yAxis(i0)) { - if (isNumeric || yAxis(i0) - s > 0.5) return -1; + if (isNumeric || yAxis(i0) - s > 0.5) return std::numeric_limits<size_t>::max(); return 0; } else if (s > yAxis(n-1)) { - if (isNumeric || s - yAxis(n-1) > 0.5) return -1; + if (isNumeric || s - yAxis(n-1) > 0.5) return std::numeric_limits<size_t>::max(); return n-1; } size_t i = i0, j = n-1, k = n/2; - double ss; for(size_t it = 0; it < n; it++) { - ss = yAxis(k); + const double ss = yAxis(k); if (ss == s ) return k; if (abs(static_cast<int>(i) - static_cast<int>(j)) <2) { @@ -230,10 +228,10 @@ size_t MantidMatrixFunction::indexY(double s)const if (ds1 < ds) { if (isNumeric || ds1 < 0.5) return j; - return -1; + return std::numeric_limits<size_t>::max(); } if (isNumeric || ds < 0.5) return i; - return -1; + return std::numeric_limits<size_t>::max(); } if (s > ss) i = k; else