diff --git a/Code/Mantid/Build/CMake/CommonSetup.cmake b/Code/Mantid/Build/CMake/CommonSetup.cmake index f4de60cfed257920e5ae049774e9ec463b20aa5c..5a18913deef7882c1374f64f880ba71f0d6259b8 100644 --- a/Code/Mantid/Build/CMake/CommonSetup.cmake +++ b/Code/Mantid/Build/CMake/CommonSetup.cmake @@ -70,6 +70,17 @@ if ( SVN_WORKING_COPY ) include( FindSubversion ) endif () +########################################################################### +# Look for OpenMP and set compiler flags if found +########################################################################### + +find_package ( OpenMP ) +if ( OPENMP_FOUND ) +# add_definitions ( ${OpenMP_CXX_FLAGS} ) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" ) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" ) +endif () + ########################################################################### # Set up the unit tests target ########################################################################### diff --git a/Code/Mantid/Framework/CMakeLists.txt b/Code/Mantid/Framework/CMakeLists.txt index e4c46e38022452d9900e0b292f6fc98e2824d9f0..29c83ec8fcff1c9101c589b55a27571b7ded556f 100644 --- a/Code/Mantid/Framework/CMakeLists.txt +++ b/Code/Mantid/Framework/CMakeLists.txt @@ -61,17 +61,6 @@ set ( MANTIDLIBS ${Boost_LIBRARIES} ${POCO_LIBRARIES} ${TCMALLOC_LIBRARY} ) # gsl is currently needed by Geometry, Algorithms & Curvefitting find_package ( GSL REQUIRED ) -########################################################################### -# Look for OpenMP and set compiler flags if found -########################################################################### - -find_package ( OpenMP ) -if ( OPENMP_FOUND ) -# add_definitions ( ${OpenMP_CXX_FLAGS} ) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" ) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" ) -endif () - ########################################################################### # Now add the packages one-by-one, building up the dependencies as we go ########################################################################### diff --git a/Code/Mantid/MantidPlot/src/Graph.cpp b/Code/Mantid/MantidPlot/src/Graph.cpp index ac8f3344fabb30d25c85cfb26ee07308cd052de8..b5dbd0fc9ae57bb9801eb6fe01bcf521fa50cf99 100644 --- a/Code/Mantid/MantidPlot/src/Graph.cpp +++ b/Code/Mantid/MantidPlot/src/Graph.cpp @@ -4918,9 +4918,10 @@ Spectrogram* Graph::plotSpectrogram(Spectrogram *d_spectrogram, CurveType type) d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, true); } else if (type == ColorMap) - { d_spectrogram->mutableColorMap().changeScaleType(GraphOptions::Linear); - d_spectrogram->setDefaultColorMap(); - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, false); + { + d_spectrogram->mutableColorMap().changeScaleType(GraphOptions::Linear); + d_spectrogram->setDefaultColorMap(); + d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, false); } c_keys.resize(++n_curves); c_keys[n_curves-1] = d_plot->insertCurve(d_spectrogram); @@ -4944,8 +4945,7 @@ Spectrogram* Graph::plotSpectrogram(Spectrogram *d_spectrogram, CurveType type) d_plot->setAxisScaleDiv(QwtPlot::yRight, *d_plot->axisScaleDiv(QwtPlot::yRight)); for (int i=0; i < QwtPlot::axisCnt; i++) - {updatedaxis.push_back(0); - } + {updatedaxis.push_back(0); } return d_spectrogram; } diff --git a/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.cpp b/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.cpp index 80b8f1fa83918954f399b2e5dd9933672d82e17a..7520a735f6961786d385d6314ec7e144b90efa58 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.cpp @@ -1,4 +1,5 @@ #include "MantidMatrix.h" +#include "MantidKernel/Timer.h" #include "MantidUI.h" #include "../Graph3D.h" #include "../ApplicationWindow.h" @@ -40,7 +41,9 @@ #include <algorithm> #include <limits> +using namespace Mantid; using namespace Mantid::API; +using namespace Mantid::Kernel; //Mantid::Kernel::Logger & MantidMatrix::g_log=Mantid::Kernel::Logger::get("MantidMatrix"); MantidMatrix::MantidMatrix(Mantid::API::MatrixWorkspace_sptr ws, ApplicationWindow* parent, const QString& label, const QString& name, int start, int end) @@ -382,50 +385,80 @@ void MantidMatrix::range(double *min, double *max) if (!m_are_min_max_set) { //this is here to fill m_min and m_max with numbers that aren't nan - initialMaxMin(); + m_min = std::numeric_limits<double>::max(); + m_max = -std::numeric_limits<double>::max(); - int rows = numRows(); - int cols = numCols(); - for(int i=0; i<rows; i++){ - for(int j=0; j<cols; j++){ - double aux = cell(i, j); - if (fabs(aux) == std::numeric_limits<double>::infinity() || aux != aux) + if (this->m_workspace) + { + + PARALLEL_FOR1(m_workspace) + for (int wi=0; wi < m_workspace->getNumberHistograms(); wi++) + { + double local_min, local_max; + const MantidVec & Y = m_workspace->readY(wi); + + local_min = std::numeric_limits<double>::max(); + local_max = -std::numeric_limits<double>::max(); + + for (size_t i=0; i < Y.size(); i++) { - continue; + double aux = Y[i]; + if (fabs(aux) == std::numeric_limits<double>::infinity() || aux != aux) + continue; + if (aux < local_min) + local_min = aux; + if (aux > local_max) + local_max = aux; } - if (aux <= m_min) - m_min = aux; - if (aux >= m_max) - m_max = aux; + // Now merge back the local min max + PARALLEL_CRITICAL(MantidMatrix_range_max) + { + if (local_max > m_max) + m_max = local_max; + } + PARALLEL_CRITICAL(MantidMatrix_range_min) + { + if (local_min < m_min) + m_min = local_min; + } } + m_are_min_max_set = true; } - m_are_min_max_set = true; - } + // Make up some reasonable values if nothing was found + if (m_min == std::numeric_limits<double>::max()) + m_min = 0; + if (m_max == -std::numeric_limits<double>::max()) + m_max = m_min + 1e6; + +// // ---- VERY SLOW OLD ALGORITHM ----- +// int rows = numRows(); +// int cols = numCols(); +// for(int i=0; i<rows; i++){ +// for(int j=0; j<cols; j++){ +// double aux = cell(i, j); +// if (fabs(aux) == std::numeric_limits<double>::infinity() || aux != aux) +// { +// continue; +// } +// if (aux <= m_min) +// m_min = aux; +// +// if (aux >= m_max) +// m_max = aux; +// } +// +// m_are_min_max_set = true; +// } + + + } *min = m_min; *max = m_max; } -//these values will be overwritten below, unless the whole matrix contains only infinites and nan -void MantidMatrix::initialMaxMin() -{ - int rows = numRows(); - int cols = numCols(); - for(int i=0; i<rows; i++){ - for(int j=0; j<cols; j++){ - double aux = cell(i, j); - if (isANumber(aux)) - { - m_min = aux; - m_max = m_min; - return; - } - } - } - //all the data is nan, which is really an error. Return a default, largish range - m_min = 0; - m_max = 1e6; -} + + /** Sets new minimum and maximum Y-values which can be displayed in a 2D graph */ @@ -942,7 +975,8 @@ Spectrogram* MantidMatrix::plotSpectrogram(Graph* plot,ApplicationWindow* app,Gr range(&minz,&maxz); Spectrogram *spgrm = plot->plotSpectrogram(&m_funct, m_spectrogramRows, m_spectrogramCols, boundingRect(), minz, maxz, type); if( spgrm ) - { spgrm->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); + { + spgrm->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); spgrm->setDisplayMode(QwtPlotSpectrogram::ContourMode, false); if(project) { @@ -952,18 +986,18 @@ Spectrogram* MantidMatrix::plotSpectrogram(Graph* plot,ApplicationWindow* app,Gr if(!prjData->getGrayScale())spgrm->setGrayScale(); if(prjData->getContourMode()) {spgrm->setDisplayMode(QwtPlotSpectrogram::ContourMode, true); - spgrm->showContourLineLabels(true); + spgrm->showContourLineLabels(true); } spgrm->setDefaultContourPen(prjData->getDefaultContourPen()); spgrm->setColorMapPen(false); if(prjData->getColorMapPen())spgrm->setColorMapPen(true); ContourLinesEditor* contourEditor=prjData->getContourLinesEditor(); if(contourEditor) - { - contourEditor->setSpectrogram(spgrm); - contourEditor->updateContents(); - contourEditor->updateContourLevels(); - } + { + contourEditor->setSpectrogram(spgrm); + contourEditor->updateContents(); + contourEditor->updateContourLevels(); + } } } diff --git a/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.h b/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.h index 84c499e778d1e522515966448b981505ba3cc28c..ac63b7856570ea0236660c390121aa08a858c4a9 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.h +++ b/Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.h @@ -212,8 +212,6 @@ public slots: //! Min and max values in the matrix. void range(double *min, double *max); - //! initalise m_min and m_max to non-nan values from the matrix or failing that default nan values - void initialMaxMin(); //! Set min and max values in the matrix. void setRange(double min, double max);