Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
f865dd25
Commit
f865dd25
authored
Feb 10, 2012
by
Janik Zikovsky
Browse files
Refs #4791: prepare for testing coord_t = float
Reduce warnings and avoid errors
parent
71145b17
Changes
24
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h
View file @
f865dd25
...
...
@@ -87,25 +87,19 @@ namespace Mantid
virtual
std
::
vector
<
IMDIterator
*>
createIterators
(
size_t
suggestedNumCores
=
1
,
Mantid
::
Geometry
::
MDImplicitFunction
*
function
=
NULL
)
const
=
0
;
/// Creates a new iterator pointing to the first cell in the workspace
IMDIterator
*
createIterator
(
Mantid
::
Geometry
::
MDImplicitFunction
*
function
=
NULL
)
const
;
/// Returns the (normalized) signal at a given coordinates
virtual
signal_t
getSignalAtCoord
(
const
coord_t
*
coords
,
const
Mantid
::
API
::
MDNormalization
&
normalization
)
const
=
0
;
//-------------------------------------------------------------------------------------------
/// Returns the signal (normalized by volume) at a given coordinates
/// @param coords :: coordinate as a VMD vector
/// @param normalization :: how to normalize the signal returned
signal_t
getSignalAtVMD
(
const
Mantid
::
Kernel
::
VMD
&
coords
,
const
Mantid
::
API
::
MDNormalization
&
normalization
=
Mantid
::
API
::
VolumeNormalization
)
const
{
return
this
->
getSignalAtCoord
(
coords
.
getBareArray
(),
normalization
);
}
/// Method to generate a line plot through a MD-workspace
virtual
void
getLinePlot
(
const
Mantid
::
Kernel
::
VMD
&
start
,
const
Mantid
::
Kernel
::
VMD
&
end
,
Mantid
::
API
::
MDNormalization
normalize
,
std
::
vector
<
coord_t
>
&
x
,
std
::
vector
<
signal_t
>
&
y
,
std
::
vector
<
signal_t
>
&
e
)
const
=
0
;
IMDIterator
*
createIterator
(
Mantid
::
Geometry
::
MDImplicitFunction
*
function
=
NULL
)
const
;
signal_t
getSignalAtVMD
(
const
Mantid
::
Kernel
::
VMD
&
coords
,
const
Mantid
::
API
::
MDNormalization
&
normalization
=
Mantid
::
API
::
VolumeNormalization
)
const
;
};
/// Shared pointer to the IMDWorkspace base class
...
...
Code/Mantid/Framework/API/inc/MantidAPI/ImplicitFunctionParameter.h
View file @
f865dd25
...
...
@@ -152,6 +152,22 @@ namespace Mantid
}
};
/** ElementTraits for float element types.
*/
template
<
>
struct
ElementTraits
<
float
>
{
typedef
double
ValueType
;
static
std
::
string
formatCS
(
const
ValueType
&
value
)
{
return
boost
::
str
(
boost
::
format
(
"%.4f,"
)
%
value
);
}
static
std
::
string
format
(
const
ValueType
&
value
)
{
return
boost
::
str
(
boost
::
format
(
"%.4f"
)
%
value
);
}
};
//------------------------------------------------------------------------------------
// End ElementTraits TypeTraits region
//------------------------------------------------------------------------------------
...
...
Code/Mantid/Framework/API/src/CoordTransform.cpp
View file @
f865dd25
...
...
@@ -52,7 +52,14 @@ namespace API
if
(
inputVector
.
getNumDims
()
!=
inD
)
throw
std
::
runtime_error
(
"CoordTransform::apply(): inputVector has the wrong number of coordinates!"
);
coord_t
*
outArray
=
new
coord_t
[
outD
];
#ifdef COORDT_IS_FLOAT
std
::
vector
<
coord_t
>
temp
=
inputVector
.
toVector
<
coord_t
>
();
this
->
apply
(
&
temp
[
0
],
outArray
);
#else
this
->
apply
(
inputVector
.
getBareArray
(),
outArray
);
#endif
VMD
out
(
outD
,
outArray
);
delete
[]
outArray
;
return
out
;
...
...
Code/Mantid/Framework/API/src/IMDWorkspace.cpp
View file @
f865dd25
...
...
@@ -42,6 +42,27 @@ namespace Mantid
throw
std
::
runtime_error
(
"IMDWorkspace::createIterator(): iterator creation was not successful. No iterators returned by "
+
this
->
id
()
);
return
iterators
[
0
];
}
//-------------------------------------------------------------------------------------------
/** Returns the signal (normalized by volume) at a given coordinates
*
* @param coords :: coordinate as a VMD vector
* @param normalization :: how to normalize the signal returned
* @return normalized signal
*/
signal_t
IMDWorkspace
::
getSignalAtVMD
(
const
Mantid
::
Kernel
::
VMD
&
coords
,
const
Mantid
::
API
::
MDNormalization
&
normalization
)
const
{
#ifdef COORDT_IS_FLOAT
std
::
vector
<
coord_t
>
temp
=
coords
.
toVector
<
coord_t
>
();
signal_t
out
=
this
->
getSignalAtCoord
(
&
temp
[
0
],
normalization
);
return
out
;
#else
return
this
->
getSignalAtCoord
(
coords
.
getBareArray
(),
normalization
);
#endif
}
}
}
...
...
Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDDimensionExtents.h
View file @
f865dd25
...
...
@@ -37,8 +37,8 @@ namespace Geometry
/** Empty constructor - reset everything.
* */
MDDimensionExtents
()
:
min
(
1e100
),
max
(
-
1e100
)
min
(
coord_t
(
1e30
)
),
max
(
coord_t
(
-
1e30
)
)
{
}
// ---- Public members ----------
...
...
Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDPlane.h
View file @
f865dd25
...
...
@@ -107,7 +107,7 @@ namespace Geometry
coord_t
total
=
0
;
for
(
size_t
d
=
0
;
d
<
m_nd
;
d
++
)
{
total
+=
m_normal
[
d
]
*
coords
[
d
];
total
+=
m_normal
[
d
]
*
coord_t
(
coords
[
d
]
)
;
}
return
(
total
>=
m_inequality
);
}
...
...
@@ -164,8 +164,8 @@ namespace Geometry
m_inequality
=
0
;
for
(
size_t
d
=
0
;
d
<
m_nd
;
d
++
)
{
m_normal
[
d
]
=
normal
[
d
];
m_inequality
+=
point
[
d
]
*
m_normal
[
d
];
m_normal
[
d
]
=
coord_t
(
normal
[
d
]
)
;
m_inequality
+=
coord_t
(
point
[
d
]
)
*
m_normal
[
d
];
}
}
...
...
Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDTypes.h
View file @
f865dd25
...
...
@@ -40,20 +40,16 @@ namespace Mantid
* We can change this in order to compare
* performance/memory/accuracy requirements.
*/
typedef
double
coord_t
;
// moved our of here to the coordinate and the header itself -- from coordinate header to
typedef
double
signal_t
;
// avoid strange conflict between numeric_limits and <climits> (presumably)
// win builds sometimes pick up macro max((a),(b)) (a)>(b)?((a):(b))
#ifdef max
#undef max
#endif
/// Minimum value (large negative number) that a coordinate can take
static
const
coord_t
coord_t_min
=
-
std
::
numeric_limits
<
coord_t
>::
max
();
typedef
double
coord_t
;
///
Maximum value (large positive number)
that
a
coord
inate can take
static
const
coord_t
coord_t_max
=
std
::
numeric_limits
<
coord_t
>::
max
();
///
Define indicating
that
the
coord
_t type is a float (not double)
#undef COORDT_IS_FLOAT
/** Typedef for the signal recorded in a MDBox, etc.
*/
typedef
double
signal_t
;
/** Macro TMDE to make declaring template functions
* faster. Put this macro before function declarations.
...
...
Code/Mantid/Framework/Geometry/src/MDGeometry/MDBoxImplicitFunction.cpp
View file @
f865dd25
...
...
@@ -67,7 +67,7 @@ namespace Geometry
normal_min
[
d
]
=
+
1.0
;
// Origin just needs to have its X set to the value. Other coords are irrelevant
std
::
vector
<
coord_t
>
origin_min
(
nd
,
0
);
origin_min
[
d
]
=
min
[
d
];
origin_min
[
d
]
=
coord_t
(
min
[
d
]
)
;
// Build the plane
MDPlane
p_min
(
normal_min
,
origin_min
);
this
->
addPlane
(
p_min
);
...
...
@@ -77,7 +77,7 @@ namespace Geometry
normal_max
[
d
]
=
-
1.0
;
// Origin just needs to have its X set to the value. Other coords are irrelevant
std
::
vector
<
coord_t
>
origin_max
(
nd
,
0
);
origin_max
[
d
]
=
max
[
d
];
origin_max
[
d
]
=
coord_t
(
max
[
d
]
)
;
// Build the plane
MDPlane
p_max
(
normal_max
,
origin_max
);
this
->
addPlane
(
p_max
);
...
...
Code/Mantid/Framework/Kernel/inc/MantidKernel/VMD.h
View file @
f865dd25
...
...
@@ -192,6 +192,17 @@ namespace Kernel
data
=
new
double
[
nd
];
for
(
size_t
d
=
0
;
d
<
nd
;
d
++
)
data
[
d
]
=
bareData
[
d
];
}
//-------------------------------------------------------------------------------------------
/** Constructor
* @param nd :: number of dimensions
* @param bareData :: pointer to a nd-sized bare data array */
VMD
(
size_t
nd
,
const
float
*
bareData
)
:
nd
(
nd
)
{
if
(
nd
<=
0
)
throw
std
::
invalid_argument
(
"nd must be > 0"
);
data
=
new
double
[
nd
];
for
(
size_t
d
=
0
;
d
<
nd
;
d
++
)
data
[
d
]
=
double
(
bareData
[
d
]);
}
//-------------------------------------------------------------------------------------------
/** Constructor
...
...
@@ -206,12 +217,13 @@ namespace Kernel
//-------------------------------------------------------------------------------------------
/** Constructor
* @param vector :: vector of doubles */
VMD
(
const
std
::
vector
<
double
>
&
vector
)
template
<
class
T
>
VMD
(
const
std
::
vector
<
T
>
&
vector
)
:
nd
(
vector
.
size
())
{
if
(
nd
<=
0
)
throw
std
::
invalid_argument
(
"nd must be > 0"
);
data
=
new
double
[
nd
];
for
(
size_t
d
=
0
;
d
<
nd
;
d
++
)
data
[
d
]
=
vector
[
d
];
for
(
size_t
d
=
0
;
d
<
nd
;
d
++
)
data
[
d
]
=
double
(
vector
[
d
]
)
;
}
//-------------------------------------------------------------------------------------------
...
...
@@ -297,12 +309,16 @@ namespace Kernel
}
//-------------------------------------------------------------------------------------------
/** @return the vector as a std::vector */
std
::
vector
<
double
>
toVector
()
const
/** Get the vector as a vector
* @tparam T :: type to convert to (double/float)
* @return the vector as a std::vector
*/
template
<
class
T
>
std
::
vector
<
T
>
toVector
()
const
{
std
::
vector
<
double
>
out
;
typename
std
::
vector
<
T
>
out
;
for
(
size_t
d
=
0
;
d
<
nd
;
d
++
)
out
.
push_back
(
data
[
d
]);
out
.
push_back
(
T
(
data
[
d
])
)
;
return
out
;
}
...
...
Code/Mantid/Framework/MDAlgorithms/src/MergeMD.cpp
View file @
f865dd25
...
...
@@ -113,8 +113,8 @@ namespace MDAlgorithms
size_t
numDims
=
ws0
->
getNumDims
();
// Extents to create.
std
::
vector
<
double
>
dimMin
(
numDims
,
+
1e
10
0
);
std
::
vector
<
double
>
dimMax
(
numDims
,
-
1e
10
0
);
std
::
vector
<
double
>
dimMin
(
numDims
,
+
1e
3
0
);
std
::
vector
<
double
>
dimMax
(
numDims
,
-
1e
3
0
);
// Validate each workspace
for
(
size_t
i
=
0
;
i
<
m_workspaces
.
size
();
i
++
)
...
...
Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/IMDBox.h
View file @
f865dd25
...
...
@@ -357,7 +357,7 @@ namespace MDEvents
/** Return the volume of the cell */
coord_t
getVolume
()
const
{
return
1.0
/
m_inverseVolume
;
return
coord_t
(
1.0
)
/
m_inverseVolume
;
}
//-----------------------------------------------------------------------------------------------
...
...
Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEvent.h
View file @
f865dd25
...
...
@@ -267,8 +267,16 @@ namespace MDEvents
if
(
numEvents
==
0
)
return
;
#ifdef COORDT_IS_FLOAT
if
(
file
->
getInfo
().
type
!=
::
NeXus
::
FLOAT32
)
{
// TODO: Handle old files that are recorded in DOUBLEs to load as FLOATS
throw
std
::
runtime_error
(
"loadVectorFromNexusSlab(): cannot load legacy file that is in floats yet."
);
}
#else
#endif
// Allocate the data
double
*
data
=
new
double
[
numEvents
*
(
nd
+
4
)];
coord_t
*
data
=
new
coord_t
[
numEvents
*
(
nd
+
4
)];
// Start/size descriptors
std
::
vector
<
int
>
start
(
2
,
0
);
...
...
Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDLeanEvent.h
View file @
f865dd25
...
...
@@ -356,8 +356,16 @@ namespace MDEvents
if
(
numEvents
==
0
)
return
;
#ifdef COORDT_IS_FLOAT
if
(
file
->
getInfo
().
type
!=
::
NeXus
::
FLOAT32
)
{
// TODO: Handle old files that are recorded in DOUBLEs to load as FLOATS
throw
std
::
runtime_error
(
"loadVectorFromNexusSlab(): cannot load legacy file that is in floats yet."
);
}
#else
#endif
// Allocate the data
double
*
data
=
new
double
[
numEvents
*
(
nd
+
2
)];
coord_t
*
data
=
new
coord_t
[
numEvents
*
(
nd
+
2
)];
// Start/size descriptors
std
::
vector
<
int
>
start
(
2
,
0
);
...
...
Code/Mantid/Framework/MDEvents/src/AffineMatrixParameter.cpp
View file @
f865dd25
...
...
@@ -83,7 +83,7 @@ namespace Mantid
*/
std
::
string
AffineMatrixParameter
::
toXMLString
()
const
{
std
::
vector
<
double
>
elements
=
this
->
affineMatrix
.
get_vector
();
std
::
vector
<
coord_t
>
elements
=
this
->
affineMatrix
.
get_vector
();
const
size_t
size
=
elements
.
size
();
std
::
string
parameterValue
;
...
...
Code/Mantid/Framework/MDEvents/src/AffineMatrixParameterParser.cpp
View file @
f865dd25
...
...
@@ -24,7 +24,7 @@ namespace Mantid
{
//Convenience typedefs
typedef
std
::
vector
<
std
::
string
>
VecStrings
;
typedef
std
::
vector
<
double
>
VecDoubles
;
typedef
std
::
vector
<
coord_t
>
VecDoubles
;
std
::
string
sParameterValue
=
parameterElement
->
getChildElement
(
"Value"
)
->
innerText
();
...
...
Code/Mantid/Framework/MDEvents/src/BinMD.cpp
View file @
f865dd25
...
...
@@ -471,8 +471,8 @@ namespace MDEvents
// Dimension in the MDEventWorkspace
size_t
d
=
m_dimensionToBinFrom
[
bd
];
// Corresponding extents
bin
.
m_min
[
d
]
=
m_binDimensions
[
bd
]
->
getX
(
idx
);
bin
.
m_max
[
d
]
=
m_binDimensions
[
bd
]
->
getX
(
idx
+
1
);
bin
.
m_min
[
d
]
=
coord_t
(
m_binDimensions
[
bd
]
->
getX
(
idx
)
)
;
bin
.
m_max
[
d
]
=
coord_t
(
m_binDimensions
[
bd
]
->
getX
(
idx
+
1
)
)
;
}
bin
.
m_index
=
linear_index
;
...
...
Code/Mantid/Framework/MDEvents/src/CentroidPeaksMD.cpp
View file @
f865dd25
...
...
@@ -143,13 +143,13 @@ namespace MDEvents
centroid
[
d
]
=
0.0
;
// Perform centroid
ws
->
getBox
()
->
centroidSphere
(
sphere
,
PeakRadius
*
PeakRadius
,
centroid
,
signal
);
ws
->
getBox
()
->
centroidSphere
(
sphere
,
coord_t
(
PeakRadius
*
PeakRadius
)
,
centroid
,
signal
);
// Normalize by signal
if
(
signal
!=
0.0
)
{
for
(
size_t
d
=
0
;
d
<
nd
;
d
++
)
centroid
[
d
]
/=
signal
;
centroid
[
d
]
/=
coord_t
(
signal
)
;
V3D
vecCentroid
(
centroid
[
0
],
centroid
[
1
],
centroid
[
2
]);
...
...
Code/Mantid/Framework/MDEvents/src/CoordTransformAffine.cpp
View file @
f865dd25
...
...
@@ -186,14 +186,14 @@ namespace MDEvents
basis
.
normalize
();
// The row of the affine matrix = the unit vector
for
(
size_t
j
=
0
;
j
<
basis
.
size
();
j
++
)
affineMatrix
[
i
][
j
]
=
basis
[
j
]
*
scaling
[
i
];
affineMatrix
[
i
][
j
]
=
coord_t
(
basis
[
j
]
*
scaling
[
i
]
)
;
// Now account for the translation
coord_t
transl
=
0
;
for
(
size_t
j
=
0
;
j
<
basis
.
size
();
j
++
)
transl
+=
origin
[
j
]
*
basis
[
j
];
// dot product of origin * basis aka ( X0 . U )
transl
+=
coord_t
(
origin
[
j
]
*
basis
[
j
]
)
;
// dot product of origin * basis aka ( X0 . U )
// The last column of the matrix = the translation movement
affineMatrix
[
i
][
inD
]
=
-
transl
*
scaling
[
i
];
affineMatrix
[
i
][
inD
]
=
-
transl
*
coord_t
(
scaling
[
i
]
)
;
}
// Copy into the raw matrix (for speed)
...
...
Code/Mantid/Framework/MDEvents/src/FakeMDEventData.cpp
View file @
f865dd25
...
...
@@ -114,8 +114,8 @@ namespace MDEvents
double
desiredRadius
=
params
.
back
();
boost
::
mt19937
rng
;
boost
::
uniform_real
<
double
>
u2
(
0
,
1.0
);
// Random from 0 to 1.0
boost
::
variate_generator
<
boost
::
mt19937
&
,
boost
::
uniform_real
<
double
>
>
genUnit
(
rng
,
u2
);
boost
::
uniform_real
<
coord_t
>
u2
(
0
,
1.0
);
// Random from 0 to 1.0
boost
::
variate_generator
<
boost
::
mt19937
&
,
boost
::
uniform_real
<
coord_t
>
>
genUnit
(
rng
,
u2
);
int
randomSeed
=
getProperty
(
"RandomSeed"
);
rng
.
seed
((
unsigned
int
)(
randomSeed
));
...
...
@@ -139,7 +139,7 @@ namespace MDEvents
centers
[
d
]
/=
radius
;
// Now place the point along this radius, scaled with ^1/n for uniformity.
double
radPos
=
genUnit
();
coord_t
radPos
=
genUnit
();
radPos
=
pow
(
radPos
,
1.0
/
double
(
nd
));
for
(
size_t
d
=
0
;
d
<
nd
;
d
++
)
{
...
...
Code/Mantid/Framework/MDEvents/src/MDBin.cpp
View file @
f865dd25
...
...
@@ -15,9 +15,9 @@ namespace MDEvents
:
m_signal
(
0
),
m_errorSquared
(
0
)
{
for
(
size_t
d
=
0
;
d
<
nd
;
++
d
)
m_min
[
d
]
=
coord_t_min
;
m_min
[
d
]
=
-
std
::
numeric_limits
<
coord_t
>::
max
()
;
for
(
size_t
d
=
0
;
d
<
nd
;
++
d
)
m_max
[
d
]
=
coord_t
_
max
;
m_max
[
d
]
=
+
std
::
numeric_limits
<
coord_t
>::
max
()
;
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment