Skip to content

Commit

Permalink
issue #1300: renamed isScalar --> isscalar
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeandersson committed Jun 29, 2015
1 parent d903171 commit 8998a8f
Show file tree
Hide file tree
Showing 27 changed files with 87 additions and 87 deletions.
4 changes: 2 additions & 2 deletions casadi/core/function/function.cpp
Expand Up @@ -644,7 +644,7 @@ namespace casadi {
}

inline bool checkMat(const Sparsity& arg, const Sparsity& inp) {
return arg.shape()==inp.shape() || arg.isEmpty() || arg.isScalar() ||
return arg.shape()==inp.shape() || arg.isEmpty() || arg.isscalar() ||
(inp.size2()==arg.size1() && inp.size1()==arg.size2()
&& (arg.isVector() || inp.isVector()));
}
Expand Down Expand Up @@ -751,7 +751,7 @@ namespace casadi {
} else if (arg.isEmpty()) {
// Empty matrix means set zero
return M(inp.shape());
} else if (arg.isScalar()) {
} else if (arg.isscalar()) {
// Scalar assign means set all
return M(inp, arg);
} else {
Expand Down
6 changes: 3 additions & 3 deletions casadi/core/function/function_internal.cpp
Expand Up @@ -205,7 +205,7 @@ namespace casadi {

Function FunctionInternal::gradient(int iind, int oind) {
// Assert scalar
casadi_assert_message(output(oind).isScalar(),
casadi_assert_message(output(oind).isscalar(),
"Only gradients of scalar functions allowed. Use jacobian instead.");

// Give it a suitable name
Expand All @@ -227,7 +227,7 @@ namespace casadi {

Function FunctionInternal::tangent(int iind, int oind) {
// Assert scalar
casadi_assert_message(input(iind).isScalar(),
casadi_assert_message(input(iind).isscalar(),
"Only tangent of scalar input functions allowed. Use jacobian instead.");

// Give it a suitable name
Expand All @@ -251,7 +251,7 @@ namespace casadi {
log("FunctionInternal::hessian");

// Assert scalar
casadi_assert_message(output(oind).isScalar(), "Only hessians of scalar functions allowed.");
casadi_assert_message(output(oind).isscalar(), "Only hessians of scalar functions allowed.");

// Generate gradient function
Function ret = getHessian(iind, oind);
Expand Down
4 changes: 2 additions & 2 deletions casadi/core/function/x_function_internal.hpp
Expand Up @@ -531,7 +531,7 @@ namespace casadi {

template<typename PublicType, typename DerivedType, typename MatType, typename NodeType>
MatType XFunctionInternal<PublicType, DerivedType, MatType, NodeType>::grad(int iind, int oind) {
casadi_assert_message(output(oind).isScalar(),
casadi_assert_message(output(oind).isscalar(),
"Only gradients of scalar functions allowed. Use jacobian instead.");

// Quick return if trivially empty
Expand Down Expand Up @@ -572,7 +572,7 @@ namespace casadi {

template<typename PublicType, typename DerivedType, typename MatType, typename NodeType>
MatType XFunctionInternal<PublicType, DerivedType, MatType, NodeType>::tang(int iind, int oind) {
casadi_assert_message(input(iind).isScalar(),
casadi_assert_message(input(iind).isscalar(),
"Only tangent of scalar input functions allowed. Use jacobian instead.");

// Forward seeds
Expand Down
6 changes: 3 additions & 3 deletions casadi/core/matrix/generic_matrix.hpp
Expand Up @@ -112,7 +112,7 @@ namespace casadi {
bool isDense() const { return sparsity().isDense();}

/** \brief Check if the matrix expression is scalar */
bool isScalar(bool scalar_and_dense=false) const;
bool isscalar(bool scalar_and_dense=false) const;

/** \brief Check if the matrix expression is square */
bool isSquare() const { return sparsity().isSquare();}
Expand Down Expand Up @@ -525,8 +525,8 @@ namespace casadi {
}

template<typename MatType>
bool GenericMatrix<MatType>::isScalar(bool scalar_and_dense) const {
return sparsity().isScalar(scalar_and_dense);
bool GenericMatrix<MatType>::isscalar(bool scalar_and_dense) const {
return sparsity().isscalar(scalar_and_dense);
}

#endif
Expand Down
4 changes: 2 additions & 2 deletions casadi/core/matrix/matrix.cpp
Expand Up @@ -30,12 +30,12 @@ namespace casadi {

template<>
bool Matrix<int>::isSlice(bool ind1) const {
return isScalar() || (isVector() && isDense() && Slice::isSlice(data(), ind1));
return isscalar() || (isVector() && isDense() && Slice::isSlice(data(), ind1));
}

template<>
Slice Matrix<int>::toSlice(bool ind1) const {
return isScalar() ? Slice(toScalar(), ind1) : Slice(data(), ind1);
return isscalar() ? Slice(toScalar(), ind1) : Slice(data(), ind1);
}

} // namespace casadi
2 changes: 1 addition & 1 deletion casadi/core/matrix/matrix.hpp
Expand Up @@ -156,7 +156,7 @@ namespace casadi {
using B::size2;
using B::shape;
using B::isEmpty;
using B::isScalar;
using B::isscalar;
using B::isDense;
using B::isVector;
using B::istril;
Expand Down
48 changes: 24 additions & 24 deletions casadi/core/matrix/matrix_impl.hpp
Expand Up @@ -83,7 +83,7 @@ namespace casadi {
void Matrix<DataType>::get(Matrix<DataType>& m, bool ind1,
const Slice& rr, const Slice& cc) const {
// Both are scalar
if (rr.isScalar(size1()) && cc.isScalar(size2())) {
if (rr.isscalar(size1()) && cc.isscalar(size2())) {
int k = sparsity().getNZ(rr.toScalar(size1()), cc.toScalar(size2()));
if (k>=0) {
m = at(k);
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace casadi {
void Matrix<DataType>::get(Matrix<DataType>& m, bool ind1,
const Matrix<int>& rr, const Matrix<int>& cc) const {
// Scalar
if (rr.isScalar(true) && cc.isScalar(true)) {
if (rr.isscalar(true) && cc.isscalar(true)) {
return get(m, ind1, rr.toSlice(ind1), cc.toSlice(ind1));
}

Expand Down Expand Up @@ -146,7 +146,7 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::get(Matrix<DataType>& m, bool ind1, const Slice& rr) const {
// Scalar
if (rr.isScalar(numel())) {
if (rr.isscalar(numel())) {
int r = rr.toScalar(numel());
int k = sparsity().getNZ(r % size1(), r / size1());
if (k>=0) {
Expand All @@ -164,7 +164,7 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::get(Matrix<DataType>& m, bool ind1, const Matrix<int>& rr) const {
// Scalar
if (rr.isScalar(true)) {
if (rr.isscalar(true)) {
return get(m, ind1, rr.toSlice(ind1));
}

Expand Down Expand Up @@ -195,7 +195,7 @@ namespace casadi {
void Matrix<DataType>::set(const Matrix<DataType>& m, bool ind1,
const Slice& rr, const Slice& cc) {
// Both are scalar
if (rr.isScalar(size1()) && cc.isScalar(size2()) && m.isDense()) {
if (rr.isscalar(size1()) && cc.isscalar(size2()) && m.isDense()) {
elem(rr.toScalar(size1()), cc.toScalar(size2())) = m.toScalar();
return;
}
Expand All @@ -222,7 +222,7 @@ namespace casadi {
void Matrix<DataType>::set(const Matrix<DataType>& m, bool ind1,
const Matrix<int>& rr, const Matrix<int>& cc) {
// Scalar
if (rr.isScalar(true) && cc.isScalar(true) && m.isDense()) {
if (rr.isscalar(true) && cc.isscalar(true) && m.isDense()) {
return set(m, ind1, rr.toSlice(ind1), cc.toSlice(ind1));
}

Expand All @@ -244,7 +244,7 @@ namespace casadi {

// Assert dimensions of assigning matrix
if (rr.size1() != m.size1() || cc.size1() != m.size2()) {
if (m.isScalar()) {
if (m.isscalar()) {
// m scalar means "set all"
return set(repmat(m, rr.size1(), cc.size1()), ind1, rr, cc);
} else if (rr.size1() == m.size2() && cc.size1() == m.size1()
Expand Down Expand Up @@ -298,7 +298,7 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::set(const Matrix<DataType>& m, bool ind1, const Slice& rr) {
// Scalar
if (rr.isScalar(numel()) && m.isDense()) {
if (rr.isscalar(numel()) && m.isDense()) {
int r = rr.toScalar(numel());
elem(r % size1(), r / size1()) = m.toScalar();
return;
Expand All @@ -311,7 +311,7 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::set(const Matrix<DataType>& m, bool ind1, const Matrix<int>& rr) {
// Scalar
if (rr.isScalar(true) && m.isDense()) {
if (rr.isscalar(true) && m.isDense()) {
return set(m, ind1, rr.toSlice(ind1));
}

Expand All @@ -326,7 +326,7 @@ namespace casadi {

// Project both matrices to this sparsity
return set(project(m, sp), ind1, project(rr, sp));
} else if (m.isScalar()) {
} else if (m.isscalar()) {
// m scalar means "set all"
if (m.isDense()) {
return set(Matrix<DataType>(rr.sparsity(), m), ind1, rr);
Expand Down Expand Up @@ -395,7 +395,7 @@ namespace casadi {
<< shape() << ", but supplied sparsity index has shape "
<< sp.shape() << ".");
std::vector<int> ii = sp.find();
if (m.isScalar()) {
if (m.isscalar()) {
(*this)(ii) = densify(m);
} else {
(*this)(ii) = densify(m(ii));
Expand All @@ -405,7 +405,7 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::getNZ(Matrix<DataType>& m, bool ind1, const Slice& kk) const {
// Scalar
if (kk.isScalar(nnz())) {
if (kk.isscalar(nnz())) {
m = at(kk.toScalar(nnz()));
return;
}
Expand All @@ -417,7 +417,7 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::getNZ(Matrix<DataType>& m, bool ind1, const Matrix<int>& kk) const {
// Scalar
if (kk.isScalar(true)) {
if (kk.isscalar(true)) {
return getNZ(m, ind1, kk.toSlice(ind1));
}

Expand Down Expand Up @@ -448,7 +448,7 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::setNZ(const Matrix<DataType>& m, bool ind1, const Slice& kk) {
// Scalar
if (kk.isScalar(nnz())) {
if (kk.isscalar(nnz())) {
at(kk.toScalar(nnz())) = m.toScalar();
return;
}
Expand All @@ -460,13 +460,13 @@ namespace casadi {
template<typename DataType>
void Matrix<DataType>::setNZ(const Matrix<DataType>& m, bool ind1, const Matrix<int>& kk) {
// Scalar
if (kk.isScalar(true)) {
if (kk.isscalar(true)) {
return setNZ(m, ind1, kk.toSlice(ind1));
}

// Assert dimensions of assigning matrix
if (kk.sparsity() != m.sparsity()) {
if (m.isScalar()) {
if (m.isscalar()) {
// m scalar means "set all"
if (!m.isDense()) return; // Nothing to set
return setNZ(Matrix<DataType>(kk.sparsity(), m), ind1, kk);
Expand Down Expand Up @@ -886,7 +886,7 @@ namespace casadi {

template<typename DataType>
Matrix<DataType>::Matrix(const Sparsity& sp, const Matrix<DataType>& d) {
if (d.isScalar()) {
if (d.isscalar()) {
*this = Matrix<DataType>(sp, d.toScalar(), false);
} else if (d.isVector() || d.size1()==1) {
casadi_assert(sp.nnz()==d.numel());
Expand Down Expand Up @@ -1343,7 +1343,7 @@ namespace casadi {
template<typename DataType>
Matrix<DataType> Matrix<DataType>::zz_mtimes(const Matrix<DataType> &y,
const Matrix<DataType> &z) const {
if (isScalar() || y.isScalar()) {
if (isscalar() || y.isscalar()) {
// Use element-wise multiplication if at least one factor scalar
return z + *this*y;
}
Expand Down Expand Up @@ -1389,7 +1389,7 @@ namespace casadi {
template<typename DataType>
Matrix<DataType> Matrix<DataType>::T() const {
// quick return if empty or scalar
if ((size1()==0 && size2()==0) || isScalar()) return *this;
if ((size1()==0 && size2()==0) || isscalar()) return *this;

// Create the new sparsity pattern and the mapping
std::vector<int> mapping;
Expand All @@ -1408,7 +1408,7 @@ namespace casadi {
template<typename DataType>
const DataType Matrix<DataType>::toScalar() const {
// Make sure that the matrix is 1-by-1
casadi_assert_message(isScalar(), "Can only convert 1-by-1 matrices to scalars");
casadi_assert_message(isscalar(), "Can only convert 1-by-1 matrices to scalars");

// return zero or the nonzero element
if (nnz()==1)
Expand Down Expand Up @@ -1819,7 +1819,7 @@ namespace casadi {

template<typename DataType>
double Matrix<DataType>::getValue() const {
casadi_assert(isScalar());
casadi_assert(isscalar());
if (nnz()==0) {
return 0;
} else {
Expand All @@ -1834,7 +1834,7 @@ namespace casadi {

template<typename DataType>
void Matrix<DataType>::setValue(double m) {
casadi_assert(isScalar());
casadi_assert(isscalar());
if (nnz()!=0) {
setValue(m, 0);
}
Expand Down Expand Up @@ -1906,7 +1906,7 @@ namespace casadi {
casadi_assert_message(n == size1(), "matrix must be square");

// Trivial return if scalar
if (isScalar()) return toScalar();
if (isscalar()) return toScalar();

// Trivial case 2 x 2
if (n==2) return elem(0, 0) * elem(1, 1) - elem(0, 1) * elem(1, 0);
Expand Down Expand Up @@ -2786,7 +2786,7 @@ namespace casadi {

template<typename DataType>
void Matrix<DataType>::get(double& val) const {
casadi_assert(isScalar());
casadi_assert(isscalar());
get(&val);
}

Expand Down
4 changes: 2 additions & 2 deletions casadi/core/matrix/slice.cpp
Expand Up @@ -234,15 +234,15 @@ namespace casadi {
return ret;
}

bool Slice::isScalar(int len) const {
bool Slice::isscalar(int len) const {
int start = std::min(start_, len);
int stop = std::min(stop_, len);
int nret = (stop-start)/step_ + ((stop-start)%step_!=0);
return nret==1;
}

int Slice::toScalar(int len) const {
casadi_assert(isScalar(len));
casadi_assert(isscalar(len));
casadi_assert_message(start_ >= -len && start_ < len, "Slice::getScalar: out of bounds");
return start_ >= 0 ? start_ : start_+len;
}
Expand Down
4 changes: 2 additions & 2 deletions casadi/core/matrix/slice.hpp
Expand Up @@ -69,9 +69,9 @@ namespace casadi {
std::vector<int> getAll(const Slice& outer, int len) const;

/// Is the slice a scalar
bool isScalar(int len) const;
bool isscalar(int len) const;

/// Get scalar (if isScalar)
/// Get scalar (if isscalar)
int toScalar(int len) const;

/// Check equality
Expand Down
4 changes: 2 additions & 2 deletions casadi/core/matrix/sparsity.cpp
Expand Up @@ -243,8 +243,8 @@ namespace casadi {
return (*this)->getNZ(rr, cc);
}

bool Sparsity::isScalar(bool scalar_and_dense) const {
return (*this)->isScalar(scalar_and_dense);
bool Sparsity::isscalar(bool scalar_and_dense) const {
return (*this)->isscalar(scalar_and_dense);
}

bool Sparsity::isDense() const {
Expand Down
6 changes: 3 additions & 3 deletions casadi/core/matrix/sparsity.hpp
Expand Up @@ -493,9 +493,9 @@ namespace casadi {
std::vector<Sparsity> zz_diagsplit(const std::vector<int>& offset1,
const std::vector<int>& offset2) const;
Sparsity zz_mtimes(const Sparsity& y) const {
if (isScalar()) {
if (isscalar()) {
return isDense() ? y : Sparsity(y.shape());
} else if (y.isScalar()) {
} else if (y.isscalar()) {
return y.isDense() ? *this : Sparsity(shape());
} else {
// Check dimensions
Expand Down Expand Up @@ -557,7 +557,7 @@ namespace casadi {
}

/// Is scalar?
bool isScalar(bool scalar_and_dense=false) const;
bool isscalar(bool scalar_and_dense=false) const;

/// Is dense?
bool isDense() const;
Expand Down
2 changes: 1 addition & 1 deletion casadi/core/matrix/sparsity_internal.cpp
Expand Up @@ -1947,7 +1947,7 @@ namespace casadi {
return Sparsity::triplet(d1, d2, row, col);
}

bool SparsityInternal::isScalar(bool scalar_and_dense) const {
bool SparsityInternal::isscalar(bool scalar_and_dense) const {
return size2()==1 && size1()==1 && (!scalar_and_dense || nnz()==1);
}

Expand Down

0 comments on commit 8998a8f

Please sign in to comment.