Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from b6d55dd..6f11d66
Browse files Browse the repository at this point in the history
6f11d66 Merge pull request #89 from mdaus/minTemplate
6a7345d Specify std::min overload
9a3d12a Merge pull request #88 from mdaus/equalityOverload
50ce51f this->get() changes to get()
abf7850 Overload eq/inequality operators on ScopedCopyable/CloneablePtr
3955c6b Merge pull request #87 from mdaus/fix_date_time_comment
c13ace6 Comments had incorrect capitalization for month, minute, and second
bd30fb5 Merge pull request #86 from mdaus/fix_solaris_openssl
94da2c1 Solaris needs to link in libcrypto too with SSL
9e65ada Merge pull request #85 from mdaus/icc_deprecated
5df0b98 icc has a different flag for hiding deprecated warnings
d46a71f Merge pull request #84 from mdaus/intel_cpp11_support
3fe079f Intel compiler doesn't have Wno-deprecated-declarations flag
617b608 Merge pull request #83 from mdaus/intel_cpp11_support
285f58e Adding icc check for C++11 and ensuring correct compile flag gets set (it's the same as the one gcc wants
ed7608a Merge pull request #81 from mdaus/sio-lite-python-exceptions
3e5b874 Fixed sio.lite-python not handling C++ exceptions
3d92965 Merge pull request #78 from mdaus/poly_fit_fix
89928c4 Correcting/clarifying comments
c394b18 Merge pull request #79 from mdaus/makeEnumsEdit
71f01e3 makeEnums.py now works on files with spaces between words as well as underscores.
ac0b5df Updating Python bindings to reflect fit() API change
a456127 Changing 'numCoeffs' to 'order' for clarity.  Fixing bug in Vector3 fit overloading where the returned poly was one less than what was requested.

git-subtree-dir: externals/coda-oss
git-subtree-split: 6f11d66cb7bc002f2db7f8f023bb34a01d9d0620
  • Loading branch information
asylvest committed Mar 8, 2016
1 parent 6d69d61 commit 0d23355
Show file tree
Hide file tree
Showing 15 changed files with 2,338 additions and 4,546 deletions.
23 changes: 20 additions & 3 deletions build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,11 @@ def configureCompilerOptions(self):
if re.match(solarisRegex, sys_platform):
self.env.append_value('LIB_SOCKET', 'socket')

warningFlags = '-Wall -Wno-deprecated-declarations'
warningFlags = '-Wall'
if ccCompiler == 'gcc':
warningFlags += ' -Wno-deprecated-declarations'
else:
warningFlags += ' -Wno-deprecated'
if Options.options.warningsAsErrors:
warningFlags += ' -Wfatal-errors'

Expand All @@ -865,7 +869,9 @@ def configureCompilerOptions(self):
config['cxx']['optz_fastest'] = '-O3'

gxxCompileFlags='-fPIC'
if cxxCompiler == 'g++' and self.env['cpp11support'] and gccHasCpp11():
if self.env['cpp11support'] and \
((cxxCompiler == 'g++' and gccHasCpp11()) or \
(cxxCompiler == 'icpc' and iccHasCpp11())):
gxxCompileFlags+=' -std=c++11'

self.env.append_value('CXXFLAGS', gxxCompileFlags.split())
Expand Down Expand Up @@ -1670,13 +1676,24 @@ def gccHasCpp11():
try:
output = subprocess.check_output("g++ --help=c++", stderr=subprocess.STDOUT, shell=True)
except subprocess.CalledProcessError:
#If gcc is too old for --help=, then it is too old for C++11
# If gcc is too old for --help=, then it is too old for C++11
return False
for line in output.split('\n'):
if re.search(r'-std=c\+\+11', line):
return True
return False

def iccHasCpp11():
try:
output = subprocess.check_output("icpc -help", stderr=subprocess.STDOUT, shell=True)
except subprocess.CalledProcessError:
# If icc is too old for -help, then it is too old for C++11
return False
for line in output.split('\n'):
if re.search(r'c\+\+11', line):
return True
return False

def getWscriptTargets(bld, env, path):
# Here we're taking a look at the current stack and adding on all the
# wscript's that got us to this point.
Expand Down
10 changes: 5 additions & 5 deletions build/scripts/makeEnums.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def cmpValues(x, y):

s.write("""
/*!
* \struct %s
* \struct %s
*
* Enumeration used to represent %ss
*/\n""" % (enum, enum))
Expand All @@ -85,7 +85,7 @@ def cmpValues(x, y):
s.write(' enum\n {\n')
for (i, item) in enumerate(values.items):
if item.value is not None:
s.write(' %s%s = %s' % (values.cleanPrefix, item.names[0], item.value))
s.write(' %s%s = %s' % (values.cleanPrefix, item.names[0].replace(' ', '_'), item.value))
else:
s.write(' %s%s' % (values.cleanPrefix, item.names[0]))
if i < len(values.items) - 1:
Expand All @@ -94,7 +94,7 @@ def cmpValues(x, y):
s.write(' };\n\n')

s.write(' //! Default constructor\n')
s.write(' %s(){ value = %s; }\n\n' % (enum, values.default))
s.write(' %s(){ value = %s; }\n\n' % (enum, values.default.replace(' ', '_')))

s.write(' //! string constructor\n')
s.write(' %s(std::string s)\n {\n' % enum)
Expand All @@ -108,7 +108,7 @@ def cmpValues(x, y):
names.append('%s%s' % (values.prefix, n))
for n in names:
s.write(' %sif (s == "%s")\n value = %s%s;\n' % (i > 0 and 'else ' or '',
n, values.cleanPrefix, item.names[0]))
n, values.cleanPrefix, item.names[0].replace(' ', '_')))
i += 1
s.write(' else\n throw except::InvalidFormatException(Ctxt(FmtX("Invalid enum value: %s", s.c_str())));\n')
s.write(' }\n\n')
Expand All @@ -119,7 +119,7 @@ def cmpValues(x, y):
for (i, item) in enumerate(values.items):
if item.value is not None:
idx = item.value
s.write(' case %s:\n value = %s%s;\n break;\n' % (idx, values.cleanPrefix, item.names[0]))
s.write(' case %s:\n value = %s%s;\n break;\n' % (idx, values.cleanPrefix, item.names[0].replace(' ', '_')))
try:
idx += 1
except:{}
Expand Down
41 changes: 19 additions & 22 deletions modules/c++/math.poly/include/math/poly/Fit.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,28 @@ namespace poly
*
* \param x The observable x points
* \param y The observable y solutions
* \param order The desired order of the polynomial fit
* \return A one dimensional polynomial that fits the curve
*/

template<typename Vector_T> OneD<double> fit(const Vector_T& x,
const Vector_T& y,
size_t numCoeffs)
size_t order)
{

math::linear::Vector<double> vy(y);
// n is polynomial order
size_t sizeX = x.size();

math::linear::Matrix2D<double> A(x.size(), numCoeffs + 1);
math::linear::Matrix2D<double> A(x.size(), order + 1);

for (size_t i = 0; i < sizeX; i++)
{
// The c0 coefficient is a freebie
A(i, 0) = 1;
double v = x[i];
A(i, 1) = v;
for (size_t j = 2; j <= numCoeffs; j++)
for (size_t j = 2; j <= order; j++)
{
A(i, j) = std::pow(v, (double)j);
}
Expand All @@ -82,11 +83,11 @@ template<typename Vector_T> OneD<double> fit(const Vector_T& x,
* pointers
*/
inline OneD<double> fit(size_t numObs, const double* x, const double* y,
size_t numCoeffs)
size_t order)
{
math::linear::Vector<double> xv(numObs, x);
math::linear::Vector<double> yv(numObs, y);
return math::poly::fit<math::linear::Vector<double> >(xv, yv, numCoeffs);
return math::poly::fit<math::linear::Vector<double> >(xv, yv, order);
}


Expand Down Expand Up @@ -260,7 +261,7 @@ inline math::poly::TwoD<double> fit(size_t numRows,
* \param yObs0 First set of observed y values
* \param yObs1 Second set of observed y values
* \param yObs2 Third set of observed y values
* \param numCoeffs The number of terms in the output poly (order + 1)
* \param order The desired order of the polynomial fit
* \throw Exception if all input Vectors are not equally sized
* \return A polynomial (B01, B02, B03)x^0 + (B11, B12, B13)x^1 + ... + (Bn1, Bn2, Bn3)x^n
*/
Expand All @@ -270,25 +271,21 @@ inline math::poly::OneD< math::linear::VectorN< 3, double > > fit(
const math::linear::Vector<double>& yObs0,
const math::linear::Vector<double>& yObs1,
const math::linear::Vector<double>& yObs2,
size_t numCoeffs)
size_t order)
{
size_t numObs = xObs.size();
if (yObs0.size() != numObs || yObs1.size() != numObs || yObs2.size() != numObs)
{
throw except::Exception(Ctxt("Must have the same number of observed y values as observed x values"));
}
if (numCoeffs < 1)
{
throw except::Exception(Ctxt("Number of coefficients must be >= 1"));
}

const math::poly::OneD<double> fit0 = fit(xObs, yObs0, numCoeffs);
const math::poly::OneD<double> fit1 = fit(xObs, yObs1, numCoeffs);
const math::poly::OneD<double> fit2 = fit(xObs, yObs2, numCoeffs);
const math::poly::OneD<double> fit0 = fit(xObs, yObs0, order);
const math::poly::OneD<double> fit1 = fit(xObs, yObs1, order);
const math::poly::OneD<double> fit2 = fit(xObs, yObs2, order);

math::poly::OneD< math::linear::VectorN< 3, double > > polyVector3 =
math::poly::OneD< math::linear::VectorN< 3, double > >(numCoeffs-1);
for (size_t term = 0; term < numCoeffs; term++)
math::poly::OneD< math::linear::VectorN< 3, double > >(order);
for (size_t term = 0; term <= order; term++)
{
math::linear::VectorN< 3, double >& coeffs = polyVector3[term];
coeffs[0] = fit0[term];
Expand All @@ -305,15 +302,15 @@ inline math::poly::OneD< math::linear::VectorN< 3, double > > fit(
*
* \param xObsVector Observed x values
* \param yObsMatrix Matrix with each row as a set of observed y values
* \param numCoeffs The number of terms in the output poly (order + 1)
* \param order The desired order of the polynomial fit
* \throw Exception if the matrix doesn't have 3 sets of values, i.e. 3 rows
* \return A polynomial (B01, B02, B03)x^0 + (B11, B12, B13)x^1 + ... + (Bn1, Bn2, Bn3)x^n
*/

inline math::poly::OneD< math::linear::VectorN< 3, double > > fit(
const math::linear::Vector<double>& xObsVector,
const math::linear::Matrix2D<double>& yObsMatrix,
size_t numCoeffs)
size_t order)
{
if (yObsMatrix.rows() != 3)
{
Expand All @@ -331,7 +328,7 @@ inline math::poly::OneD< math::linear::VectorN< 3, double > > fit(
yObsVector0,
yObsVector1,
yObsVector2,
numCoeffs);
order);
return polyVector3;
}

Expand All @@ -343,7 +340,7 @@ inline math::poly::OneD< math::linear::VectorN< 3, double > > fit(
* \param yObs0 First set of observed y values
* \param yObs1 Second set of observed y values
* \param yObs2 Third set of observed y values
* \param numCoeffs The number of terms in the output poly (order + 1)
* \param order The desired order of the polynomial fit
* \return A polynomial (B01, B02, B03)x^0 + (B11, B12, B13)x^1 + ... + (Bn1, Bn2, Bn3)x^n
*/

Expand All @@ -352,15 +349,15 @@ inline math::poly::OneD< math::linear::VectorN< 3, double > > fit(
const std::vector<double>& yObs0,
const std::vector<double>& yObs1,
const std::vector<double>& yObs2,
size_t numCoeffs)
size_t order)
{
// Vector size error checking will be done by the base fit() function
math::poly::OneD< math::linear::VectorN< 3, double > > polyVector3 = fit(
math::linear::Vector<double>(xObs),
math::linear::Vector<double>(yObs0),
math::linear::Vector<double>(yObs1),
math::linear::Vector<double>(yObs2),
numCoeffs);
order);
return polyVector3;
}
}
Expand Down
20 changes: 20 additions & 0 deletions modules/c++/mem/include/mem/ScopedCloneablePtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ class ScopedCloneablePtr
return *this;
}

bool operator==(const ScopedCloneablePtr<T>& rhs) const
{
if (get() == NULL && rhs.get() == NULL)
{
return true;
}

if (get() == NULL || rhs.get() == NULL)
{
return false;
}

return (*(this->mPtr) == *rhs);
}

bool operator!=(const ScopedCloneablePtr<T>& rhs) const
{
return !(*this == rhs);
}

T* get() const
{
return mPtr.get();
Expand Down
20 changes: 20 additions & 0 deletions modules/c++/mem/include/mem/ScopedCopyablePtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ class ScopedCopyablePtr
return *this;
}

bool operator==(const ScopedCopyablePtr<T>& rhs) const
{
if (get() == NULL && rhs.get() == NULL)
{
return true;
}

if (get() == NULL || rhs.get() == NULL)
{
return false;
}

return (*(this->mPtr) == *rhs);
}

bool operator!=(const ScopedCopyablePtr<T>& rhs) const
{
return !(*this == rhs);
}

T* get() const
{
return mPtr.get();
Expand Down
22 changes: 22 additions & 0 deletions modules/c++/mem/unittests/test_scoped_copyable_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,27 @@ TEST_CASE(testSyntax)
TEST_ASSERT_EQ(&*ptr, rawPtr);
TEST_ASSERT_EQ(&(ptr->val1), &(rawPtr->val1));
}

TEST_CASE(testEqualityOperator)
{
mem::ScopedCopyablePtr<int> ptr1;
mem::ScopedCopyablePtr<int> ptr2;

//Null smart pointers are equal
TEST_ASSERT(ptr1 == ptr2);

ptr1.reset(new int(4));

TEST_ASSERT(ptr1 != ptr2);

ptr2.reset(new int(5));

TEST_ASSERT_FALSE(ptr1 == ptr2);

ptr2.reset(new int(4));

TEST_ASSERT_FALSE(ptr1 != ptr2);
}
}

int main(int, char**)
Expand All @@ -149,6 +170,7 @@ int main(int, char**)
TEST_CHECK(testAssignmentOperator);
TEST_CHECK(testDestructor);
TEST_CHECK(testSyntax);
TEST_CHECK(testEqualityOperator);

return 0;
}
4 changes: 4 additions & 0 deletions modules/c++/net.ssl/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ USELIB = 'SSL'

from waflib import Options
from build import writeConfig
import sys, re

distclean = lambda p: None

Expand Down Expand Up @@ -99,6 +100,9 @@ def configure(conf):
# Update library information
if 'LIB_SSL' in conf.env:
self.uselib = conf.env['LIB_SSL']
solarisRegex = r'sparc-sun.*|i.86-pc-solaris.*|sunos'
if re.match(solarisRegex, sys.platform):
self.uselib += ['crypto']
if 'LIBPATH_SSL' in conf.env:
self.libpath = conf.env['LIBPATH_SSL']
if 'INCLUDES_SSL' in conf.env:
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/net/tests/TCPServerSpeedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int main(int argc, char** argv)
sys::Uint64_T numBytes;
client->recv(&numBytes, sizeof(sys::Uint64_T));

std::vector<sys::ubyte> bufferVec(std::min(numBytes, bufferSize));
std::vector<sys::ubyte> bufferVec(std::min<sys::Uint64_T>(numBytes, bufferSize));
sys::ubyte* const buffer = &bufferVec[0];

// Then receive all the bytes
Expand All @@ -68,7 +68,7 @@ int main(int argc, char** argv)
while (numBytesReceived < numBytes)
{
const size_t numBytesToReceive =
std::min(bufferSize, numBytesReceived - numBytes);
std::min<sys::Uint64_T>(bufferSize, numBytesReceived - numBytes);

numBytesReceived += client->recv(buffer, numBytesToReceive);
}
Expand Down
6 changes: 3 additions & 3 deletions modules/c++/sys/include/sys/DateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ class DateTime
/*!
* format the DateTime string
* y = year (YYYY)
* M = month (MM)
* m = month (MM)
* d = day (DD)
* H = hour (hh)
* m = minute (mm)
* s = second (ss)
* M = minute (mm)
* S = second (ss)
*/
std::string format(const std::string& formatStr) const;

Expand Down
Loading

0 comments on commit 0d23355

Please sign in to comment.