1 #ifndef SimTK_SIMMATRIX_BIGMATRIX_H_
2 #define SimTK_SIMMATRIX_BIGMATRIX_H_
378 { helper.
fillWith(reinterpret_cast<const Scalar*>(&initialValue)); }
391 const ELT* cppInitialValuesByRow)
410 int spacing,
const Scalar* data)
412 commitment, character, spacing, data) {}
417 int spacing,
Scalar* data)
419 commitment, character, spacing, data) {}
426 : helper(commitment, source, shallow) {}
430 : helper(commitment, source, shallow) {}
434 : helper(commitment, source, deep) {}
450 { helper = b.helper;
return *
this; }
452 { helper.
addIn(b.helper);
return *
this; }
454 { helper.
subIn(b.helper);
return *
this; }
487 updDiag().elementwiseAddScalarInPlace(s);
496 updDiag().elementwiseSubtractScalarInPlace(s);
504 updDiag().elementwiseAddScalarInPlace(s);
545 template <
class EE>
inline void
548 template <
class EE>
inline typename EltResult<EE>::Mul
558 template <
class EE>
inline void
561 template <
class EE>
inline typename EltResult<EE>::Mul
571 template <
class ER,
class EC>
inline MatrixBase&
574 template <
class ER,
class EC>
inline void
578 template <
class ER,
class EC>
inline typename EltResult<typename VectorBase<ER>::template EltResult<EC>::Mul>::Mul
597 {
return elementwiseAssign<Real>(Real(s)); }
620 template <
class S>
inline void
623 template <
class S>
inline typename EltResult<S>::Add
640 template <
class S>
inline void
643 template <
class S>
inline typename EltResult<S>::Sub
661 template <
class S>
inline void
669 elementwiseSubtractFromScalar<S>(s,out);
677 template <
class EE>
inline void
680 template <
class EE>
inline typename EltResult<EE>::Mul
683 elementwiseMultiply<EE>(m,out);
691 template <
class EE>
inline void
699 elementwiseMultiplyFromLeft<EE>(m,out);
707 template <
class EE>
inline void
710 template <
class EE>
inline typename EltResult<EE>::Dvd
713 elementwiseDivide<EE>(m,out);
721 template <
class EE>
inline void
729 elementwiseDivideFromLeft<EE>(m,out);
754 {
return block(i,j,m,n); }
795 void dump(
const char* msg=0)
const {
816 template <
class ELT_A,
class ELT_B>
820 helper.
matmul(beta,alpha,A.helper,B.helper);
832 const ELT&
getElt(
int i,
int j)
const {
return *
reinterpret_cast<const ELT*
>(helper.
getElt(i,j)); }
833 ELT&
updElt(
int i,
int j) {
return *
reinterpret_cast< ELT*
>(helper.
updElt(i,j)); }
843 { helper.
getAnyElt(i,j,reinterpret_cast<Scalar*>(&value)); }
853 for(
int j=0;j<nc;++j)
854 for (
int i=0; i<nr; ++i)
867 for(
int j=0;j<nc;++j)
868 for (
int i=0; i<nr; ++i)
890 for(
int j=0;j<nc;++j)
891 for (
int i=0; i<nr; ++i)
918 const int cols =
ncol();
920 for (
int j = 0; j < cols; ++j)
921 helper.
colSum(j, reinterpret_cast<Scalar*>(&row[j]));
929 const int rows =
nrow();
931 for (
int i = 0; i < rows; ++i)
932 helper.
rowSum(i, reinterpret_cast<Scalar*>(&col[i]));
1184 { Base::template rowScaleInPlace<EE>(v);
return *
this; }
1198 "Vector::normRMS() only defined for scalar elements.");
1199 const int n =
nrow();
1201 if (worstOne) *worstOne = -1;
1209 for (
int i=0; i<n; ++i) {
1211 if (v2 > maxsq) maxsq=v2, *worstOne=i;
1215 for (
int i=0; i<n; ++i) {
1234 "Vector::weightedNormRMS() only defined for scalar elements"
1236 const int n =
nrow();
1237 assert(w.
nrow()==n);
1239 if (worstOne) *worstOne = -1;
1247 for (
int i=0; i<n; ++i) {
1249 if (wv2 > maxsq) maxsq=wv2, *worstOne=i;
1253 for (
int i=0; i<n; ++i) {
1269 "Vector::normInf() only defined for scalar elements.");
1270 const int n =
nrow();
1272 if (worstOne) *worstOne = -1;
1279 for (
int i=0; i<n; ++i) {
1281 if (a > maxabs) maxabs=a, *worstOne=i;
1284 for (
int i=0; i<n; ++i) {
1286 if (a > maxabs) maxabs=a;
1302 "Vector::weightedNormInf() only defined for scalar elements"
1304 const int n =
nrow();
1305 assert(w.
nrow()==n);
1307 if (worstOne) *worstOne = -1;
1314 for (
int i=0; i<n; ++i) {
1316 if (wv > maxabs) maxabs=wv, *worstOne=i;
1319 for (
int i=0; i<n; ++i) {
1321 if (wv > maxabs) maxabs=wv;
1348 { Base::template elementwiseMultiplyInPlace<EE>(r);
return *
this; }
1350 { Base::template elementwiseMultiply<EE>(v,out); }
1356 { Base::template elementwiseMultiplyFromLeftInPlace<EE>(r);
return *
this; }
1357 template <
class EE>
inline void
1362 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
1368 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
1374 { Base::template elementwiseDivideInPlace<EE>(r);
return *
this; }
1376 { Base::template elementwiseDivide<EE>(v,out); }
1382 { Base::template elementwiseDivideFromLeftInPlace<EE>(r);
return *
this; }
1383 template <
class EE>
inline void
1388 Base::template elementwiseDivideFromLeft<EE>(v,out);
1394 Base::template elementwiseDivideFromLeft<EE>(v,out);
1495 template <
class ELT>
class RowVectorBase :
public MatrixBase<ELT> {
1496 typedef MatrixBase<ELT> Base;
1497 typedef typename CNT<ELT>::Scalar Scalar;
1498 typedef typename CNT<ELT>::Number Number;
1499 typedef typename CNT<ELT>::StdNumber StdNumber;
1500 typedef RowVectorBase<ELT> T;
1501 typedef RowVectorBase<typename CNT<ELT>::TAbs> TAbs;
1502 typedef RowVectorBase<typename CNT<ELT>::TNeg> TNeg;
1503 typedef VectorView_<typename CNT<ELT>::THerm> THerm;
1619 { Base::template colScaleInPlace<EE>(v);
return *
this; }
1621 {
return Base::template colScale<EE>(v,out); }
1628 { Base::template elementwiseMultiplyInPlace<EE>(r);
return *
this; }
1630 { Base::template elementwiseMultiply<EE>(v,out); }
1636 { Base::template elementwiseMultiplyFromLeftInPlace<EE>(r);
return *
this; }
1637 template <
class EE>
inline void
1642 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
1644 template <
class EE>
inline
1648 Base::template elementwiseMultiplyFromLeft<EE>(v,out);
1654 { Base::template elementwiseDivideInPlace<EE>(r);
return *
this; }
1656 { Base::template elementwiseDivide<EE>(v,out); }
1662 { Base::template elementwiseDivideFromLeftInPlace<EE>(r);
return *
this; }
1663 template <
class EE>
inline void
1667 Base::template elementwiseDivideFromLeft<EE>(v,out);
1669 template <
class EE>
inline
1673 Base::template elementwiseDivideFromLeft<EE>(v,out);
1775 template <
class ELT>
class MatrixView_ :
public MatrixBase<ELT> {
1776 typedef MatrixBase<ELT> Base;
1777 typedef typename CNT<ELT>::Scalar S;
1778 typedef typename CNT<ELT>::StdNumber StdNumber;
1837 template <
class ELT>
class DeadMatrixView_ :
public MatrixView_<ELT> {
1838 typedef MatrixView_<ELT> Base;
1839 typedef typename CNT<ELT>::Scalar S;
1840 typedef typename CNT<ELT>::StdNumber StdNumber;
1876 template <
class ELT>
inline
1878 :
Base(dead.updHelper().stealRep()) {}
1882 if (Base::getHelper().getCharacterCommitment().isSatisfiedBy(dead.getMatrixCharacter()))
1883 Base::updHelper().replaceRep(dead.updHelper().stealRep());
1885 Base::operator=(dead);
1920 Base::operator=(src);
return *
this;
1937 Matrix_(
int m,
int n,
const ELT* cppInitialValuesByRow)
1942 Matrix_(
int m,
int n,
int leadingDim,
const S* data)
1944 leadingDim, data) {}
1947 leadingDim, data) {}
1950 template <
int M,
int N,
int CS,
int RS>
1953 {
for (
int i = 0; i < M; ++i)
1954 for (
int j = 0; j < N; ++j)
1955 this->updElt(i, j) = mat(i, j); }
1960 { Base::operator=(m);
return*
this; }
1962 { Base::operator+=(m);
return*
this; }
1964 { Base::operator-=(m);
return*
this; }
1980 std::stringstream stream;
1982 return stream.str();
1985 const ELT&
get(
int i,
int j)
const {
return this->getElt(i,j); }
1987 void set(
int i,
int j,
const ELT& value) { this->updElt(i,j)=value; }
2002 template <
class ELT>
class VectorView_ :
public VectorBase<ELT> {
2003 typedef VectorBase<ELT> Base;
2004 typedef typename CNT<ELT>::Scalar S;
2005 typedef typename CNT<ELT>::Number Number;
2006 typedef typename CNT<ELT>::StdNumber StdNumber;
2007 typedef VectorView_<ELT> T;
2008 typedef VectorView_< typename CNT<ELT>::TNeg > TNeg;
2009 typedef RowVectorView_< typename CNT<ELT>::THerm > THerm;
2025 Base::operator=(v);
return *
this;
2037 { Base::operator=(m);
return*
this; }
2039 { Base::operator+=(m);
return*
this; }
2041 { Base::operator-=(m);
return*
this; }
2060 template <
class ELT>
class Vector_ :
public VectorBase<ELT> {
2061 typedef typename CNT<ELT>::Scalar S;
2062 typedef typename CNT<ELT>::Number Number;
2063 typedef typename CNT<ELT>::StdNumber StdNumber;
2064 typedef typename CNT<ELT>::TNeg ENeg;
2065 typedef VectorBase<ELT> Base;
2066 typedef VectorBase<ENeg> BaseNeg;
2081 Base::operator=(src);
return*
this;
2086 Vector_(
int m,
const ELT* cppInitialValues) :
Base(m, cppInitialValues) {}
2099 Vector_(
int m,
int stride,
const S* data,
bool) :
Base(m, stride, data) {}
2105 for (
int i = 0; i < M; ++i)
2106 this->updElt(i, 0) = v(i);
2112 { Base::operator=(m);
return*
this; }
2114 { Base::operator+=(m);
return*
this; }
2116 { Base::operator-=(m);
return*
this; }
2126 std::stringstream stream;
2128 return stream.str();
2131 const ELT&
get(
int i)
const {
return (*
this)[i]; }
2133 void set (
int i,
const ELT& value) { (*this)[i]=value; }
2148 template <
class ELT>
class RowVectorView_ :
public RowVectorBase<ELT> {
2149 typedef RowVectorBase<ELT> Base;
2150 typedef typename CNT<ELT>::Scalar S;
2151 typedef typename CNT<ELT>::Number Number;
2152 typedef typename CNT<ELT>::StdNumber StdNumber;
2153 typedef RowVectorView_<ELT> T;
2154 typedef RowVectorView_< typename CNT<ELT>::TNeg > TNeg;
2155 typedef VectorView_< typename CNT<ELT>::THerm > THerm;
2171 Base::operator=(r);
return *
this;
2183 { Base::operator=(m);
return*
this; }
2185 { Base::operator+=(m);
return*
this; }
2187 { Base::operator-=(m);
return*
this; }
2207 template <
class ELT>
class RowVector_ :
public RowVectorBase<ELT> {
2208 typedef typename CNT<ELT>::Scalar S;
2209 typedef typename CNT<ELT>::Number Number;
2210 typedef typename CNT<ELT>::StdNumber StdNumber;
2211 typedef typename CNT<ELT>::TNeg ENeg;
2213 typedef RowVectorBase<ELT> Base;
2214 typedef RowVectorBase<ENeg> BaseNeg;
2229 Base::operator=(src);
return*
this;
2253 for (
int i = 0; i < M; ++i)
2254 this->updElt(0, i) = v(i);
2260 { Base::operator=(b);
return*
this; }
2262 { Base::operator+=(b);
return*
this; }
2264 { Base::operator-=(b);
return*
this; }
2279 template <
class ELT>
inline MatrixView_<ELT>
2336 helper,0,j,nrow(),1);
2345 helper,0,j,nrow(),1);
2354 helper,i,0,1,ncol());
2363 helper,i,0,1,ncol());
2371 assert(v.
nrow() == nrow());
2372 for (
int i=0; i < nrow(); ++i)
2377 template <
class ELT>
template <
class EE>
inline void
2379 assert(v.
nrow() == nrow());
2380 out.
resize(nrow(), ncol());
2381 for (
int j=0; j<ncol(); ++j)
2382 for (
int i=0; i<nrow(); ++i)
2383 out(i,j) = (*this)(i,j) * v[i];
2390 assert(v.
nrow() == ncol());
2391 for (
int j=0; j < ncol(); ++j)
2396 template <
class ELT>
template <
class EE>
inline void
2398 assert(v.
nrow() == ncol());
2399 out.
resize(nrow(), ncol());
2400 for (
int j=0; j<ncol(); ++j)
2401 for (
int i=0; i<nrow(); ++i)
2402 out(i,j) = (*this)(i,j) * v[j];
2407 template <
class ELT>
template <
class ER,
class EC>
inline MatrixBase<ELT>&
2409 assert(r.
nrow()==nrow() && c.
nrow()==ncol());
2410 for (
int j=0; j<ncol(); ++j)
2411 for (
int i=0; i<nrow(); ++i)
2412 (*
this)(i,j) *= (r[i]*c[j]);
2416 template <
class ELT>
template <
class ER,
class EC>
inline void
2423 assert(r.
nrow()==nrow() && c.
nrow()==ncol());
2424 out.
resize(nrow(), ncol());
2425 for (
int j=0; j<ncol(); ++j)
2426 for (
int i=0; i<nrow(); ++i)
2427 out(i,j) = (*this)(i,j) * (r[i]*c[j]);
2433 for (
int j=0; j<ncol(); ++j)
2434 for (
int i=0; i<nrow(); ++i)
2442 const int nr=nrow(), nc=ncol();
2443 for (
int j=0; j<nc; ++j)
2444 for (
int i=0; i<nr; ++i) {
2445 ELT& e = updElt(i,j);
2451 template <
class ELT>
inline void
2453 const int nr=nrow(), nc=ncol();
2455 for (
int j=0; j<nc; ++j)
2456 for (
int i=0; i<nr; ++i)
2463 for (
int j=0; j<ncol(); ++j)
2464 for (
int i=0; i<nrow(); ++i)
2469 template <
class ELT>
template <
class S>
inline void
2474 const int nr=nrow(), nc=ncol();
2476 for (
int j=0; j<nc; ++j)
2477 for (
int i=0; i<nr; ++i)
2478 out(i,j) = (*this)(i,j) + s;
2484 for (
int j=0; j<ncol(); ++j)
2485 for (
int i=0; i<nrow(); ++i)
2490 template <
class ELT>
template <
class S>
inline void
2495 const int nr=nrow(), nc=ncol();
2497 for (
int j=0; j<nc; ++j)
2498 for (
int i=0; i<nr; ++i)
2499 out(i,j) = (*this)(i,j) - s;
2505 const int nr=nrow(), nc=ncol();
2506 for (
int j=0; j<nc; ++j)
2507 for (
int i=0; i<nr; ++i) {
2508 ELT& e = updElt(i,j);
2514 template <
class ELT>
template <
class S>
inline void
2519 const int nr=nrow(), nc=ncol();
2521 for (
int j=0; j<nc; ++j)
2522 for (
int i=0; i<nr; ++i)
2523 out(i,j) = s - (*this)(i,j);
2529 const int nr=nrow(), nc=ncol();
2530 assert(r.
nrow()==nr && r.
ncol()==nc);
2531 for (
int j=0; j<nc; ++j)
2532 for (
int i=0; i<nr; ++i)
2533 (*
this)(i,j) *= r(i,j);
2537 template <
class ELT>
template <
class EE>
inline void
2542 const int nr=nrow(), nc=ncol();
2543 assert(r.
nrow()==nr && r.
ncol()==nc);
2545 for (
int j=0; j<nc; ++j)
2546 for (
int i=0; i<nr; ++i)
2547 out(i,j) = (*this)(i,j) * r(i,j);
2553 const int nr=nrow(), nc=ncol();
2554 assert(r.
nrow()==nr && r.
ncol()==nc);
2555 for (
int j=0; j<nc; ++j)
2556 for (
int i=0; i<nr; ++i) {
2557 ELT& e = updElt(i,j);
2563 template <
class ELT>
template <
class EE>
inline void
2568 const int nr=nrow(), nc=ncol();
2569 assert(r.
nrow()==nr && r.
ncol()==nc);
2571 for (
int j=0; j<nc; ++j)
2572 for (
int i=0; i<nr; ++i)
2573 out(i,j) = r(i,j) * (*this)(i,j);
2579 const int nr=nrow(), nc=ncol();
2580 assert(r.
nrow()==nr && r.
ncol()==nc);
2581 for (
int j=0; j<nc; ++j)
2582 for (
int i=0; i<nr; ++i)
2583 (*
this)(i,j) /= r(i,j);
2587 template <
class ELT>
template <
class EE>
inline void
2592 const int nr=nrow(), nc=ncol();
2593 assert(r.
nrow()==nr && r.
ncol()==nc);
2595 for (
int j=0; j<nc; ++j)
2596 for (
int i=0; i<nr; ++i)
2597 out(i,j) = (*this)(i,j) / r(i,j);
2602 const int nr=nrow(), nc=ncol();
2603 assert(r.
nrow()==nr && r.
ncol()==nc);
2604 for (
int j=0; j<nc; ++j)
2605 for (
int i=0; i<nr; ++i) {
2606 ELT& e = updElt(i,j);
2612 template <
class ELT>
template <
class EE>
inline void
2617 const int nr=nrow(), nc=ncol();
2618 assert(r.
nrow()==nr && r.
ncol()==nc);
2620 for (
int j=0; j<nc; ++j)
2621 for (
int i=0; i<nr; ++i)
2622 out(i,j) = r(i,j) / (*this)(i,j);
2646 template <
class E1,
class E2>
2662 template <
class E1,
class E2>
2663 Matrix_<typename CNT<E1>::template Result<E2>::Sub>
2684 template <
class E> Matrix_<E>
2688 template <
class E> Matrix_<E>
2692 template <
class E> Matrix_<E>
2697 template <
class E> Matrix_<E>
2701 template <
class E> Matrix_<E>
2705 template <
class E> Matrix_<E>
2715 template <
class E1,
class E2>
2716 Vector_<typename CNT<E1>::template Result<E2>::Add>
2728 template <
class E1,
class E2>
2729 Vector_<typename CNT<E1>::template Result<E2>::Sub>
2746 template <
class E> Vector_<E>
2750 template <
class E> Vector_<E>
2754 template <
class E> Vector_<E>
2759 template <
class E> Vector_<E>
2763 template <
class E> Vector_<E>
2767 template <
class E> Vector_<E>
2775 template <
class E1,
int M,
class E2,
int S>
2776 Vector_<typename CNT<E1>::template Result< Vec<M,E2,S> >::Mul>
2779 for (
int i=0; i < v.
nrow(); ++i)
2785 template <
class E1,
int M,
class E2,
int S>
2786 Vector_<typename Vec<M,E2,S>::template Result<E1>::Mul>
2789 for (
int i=0; i < v.
nrow(); ++i)
2795 template <
class E1,
int N,
class E2,
int S>
2796 Vector_<typename CNT<E1>::template Result< Row<N,E2,S> >::Mul>
2799 for (
int i=0; i < v.
nrow(); ++i)
2805 template <
class E1,
int N,
class E2,
int S>
2806 Vector_<typename Row<N,E2,S>::template Result<E1>::Mul>
2809 for (
int i=0; i < v.
nrow(); ++i)
2815 template <
class E1,
int M,
int N,
class E2,
int S1,
int S2>
2816 Vector_<typename CNT<E1>::template Result< Mat<M,N,E2,S1,S2> >::Mul>
2819 for (
int i=0; i < v.
nrow(); ++i)
2825 template <
class E1,
int M,
int N,
class E2,
int S1,
int S2>
2826 Vector_<typename Mat<M,N,E2,S1,S2>::template Result<E1>::Mul>
2829 for (
int i=0; i < v.
nrow(); ++i)
2835 template <
class E1,
int M,
class E2,
int S>
2836 Vector_<typename CNT<E1>::template Result< SymMat<M,E2,S> >::Mul>
2839 for (
int i=0; i < v.
nrow(); ++i)
2845 template <
class E1,
int M,
class E2,
int S>
2846 Vector_<typename SymMat<M,E2,S>::template Result<E1>::Mul>
2849 for (
int i=0; i < v.
nrow(); ++i)
2860 template <
class E1,
class E2>
2861 RowVector_<typename CNT<E1>::template Result<E2>::Add>
2873 template <
class E1,
class E2>
2874 RowVector_<typename CNT<E1>::template Result<E2>::Sub>
2891 template <
class E> RowVector_<E>
2895 template <
class E> RowVector_<E>
2899 template <
class E> RowVector_<E>
2904 template <
class E> RowVector_<E>
2908 template <
class E> RowVector_<E>
2912 template <
class E> RowVector_<E>
2921 template <
class E1,
int M,
class E2,
int S>
2922 RowVector_<typename CNT<E1>::template Result< Vec<M,E2,S> >::Mul>
2925 for (
int i=0; i < v.ncol(); ++i)
2931 template <
class E1,
int M,
class E2,
int S>
2932 RowVector_<typename Vec<M,E2,S>::template Result<E1>::Mul>
2935 for (
int i=0; i < v.ncol(); ++i)
2941 template <
class E1,
int N,
class E2,
int S>
2942 RowVector_<typename CNT<E1>::template Result< Row<N,E2,S> >::Mul>
2945 for (
int i=0; i < v.ncol(); ++i)
2951 template <
class E1,
int N,
class E2,
int S>
2952 RowVector_<typename Row<N,E2,S>::template Result<E1>::Mul>
2955 for (
int i=0; i < v.ncol(); ++i)
2961 template <
class E1,
int M,
int N,
class E2,
int S1,
int S2>
2962 RowVector_<typename CNT<E1>::template Result< Mat<M,N,E2,S1,S2> >::Mul>
2965 for (
int i=0; i < v.ncol(); ++i)
2971 template <
class E1,
int M,
int N,
class E2,
int S1,
int S2>
2972 RowVector_<typename Mat<M,N,E2,S1,S2>::template Result<E1>::Mul>
2975 for (
int i=0; i < v.ncol(); ++i)
2981 template <
class E1,
int M,
class E2,
int S>
2982 RowVector_<typename CNT<E1>::template Result< SymMat<M,E2,S> >::Mul>
2985 for (
int i=0; i < v.ncol(); ++i)
2991 template <
class E1,
int M,
class E2,
int S>
2992 RowVector_<typename SymMat<M,E2,S>::template Result<E1>::Mul>
2995 for (
int i=0; i < v.ncol(); ++i)
3011 template <
class E1,
class E2>
3012 typename CNT<E1>::template Result<E2>::Mul
3014 assert(r.ncol() == v.
nrow());
3016 for (
int j=0; j < r.ncol(); ++j)
3021 template <
class E1,
class E2>
3022 Vector_<typename CNT<E1>::template Result<E2>::Mul>
3026 for (
int i=0; i< m.
nrow(); ++i)
3031 template <
class E1,
class E2>
3032 Matrix_<typename CNT<E1>::template Result<E2>::Mul>
3038 for (
int j=0; j < res.ncol(); ++j)
3039 for (
int i=0; i < res.nrow(); ++i)
3040 res(i,j) = m1[i] * m2(j);
3056 template <
class T>
static inline
3062 if (!in.good()) {in.setstate(std::ios::failbit);
return in;}
3067 if (!out.isResizeable())
3071 const int numRequired = isFixedSize ? out.size() : 0;
3079 std::ws(in);
if (in.fail())
return in;
3081 if (isFixedSize && numRequired != 0)
3082 in.setstate(std::ios_base::failbit);
3090 typename std::iostream::int_type ch;
3091 const typename std::iostream::int_type EOFch =
3092 std::iostream::traits_type::eof();
3096 bool tildeFound =
false;
3097 ch = in.peek();
if (in.fail())
return in;
3098 assert(ch != EOFch);
3099 if ((
char)ch ==
'~') {
3103 if (in.good()) std::ws(in);
3105 if (!in.good()) {in.setstate(std::ios_base::failbit);
return in;}
3113 bool lookForCloser =
true;
3114 char openBracket, closeBracket;
3115 ch = in.peek();
if (in.fail())
return in;
3116 assert(ch != EOFch);
3118 openBracket = (char)ch;
3119 if (openBracket==
'(') {in.get(); closeBracket =
')';}
3120 else if (openBracket==
'[') {in.get(); closeBracket =
']';}
3121 else lookForCloser =
false;
3125 if (tildeFound && !lookForCloser)
3126 { in.setstate(std::ios_base::failbit);
return in;}
3132 if (in.good()) std::ws(in);
3138 assert(lookForCloser);
3139 in.setstate(std::ios::failbit);
3149 bool commaOK =
true, commaRequired =
false;
3150 bool terminatorSeen =
false;
3167 if (lookForCloser) {
3169 std::ws(in);
if (!in.good())
break;
3170 ch = in.peek(); assert(ch != EOFch);
3171 if (!in.good())
break;
3173 if (c == closeBracket) {
3175 terminatorSeen =
true;
3185 if (isFixedSize && (nextIndex == numRequired))
3189 if (commaOK && nextIndex != 0) {
3191 std::ws(in);
if (!in.good())
break;
3192 ch = in.peek(); assert(ch != EOFch);
3193 if (!in.good())
break;
3197 commaRequired =
true;
3200 { in.setstate(std::ios::failbit);
break; }
3201 else commaOK =
false;
3203 if (!in.good())
break;
3213 out.resizeKeep(out.size()+1);
3214 in >> out[nextIndex];
if (in.fail())
break;
3217 if (!in.good())
break;
3231 if (lookForCloser && !terminatorSeen)
3232 in.setstate(std::ios::failbit);
3234 if (isFixedSize && nextIndex != numRequired)
3235 in.setstate(std::ios::failbit);
3260 template <
class E>
inline void
3262 const int sz = v.
size();
3263 for (
int i=0; i < sz; ++i) {
3264 if (i != 0) o <<
" ";
3270 template <
class E>
inline void
3276 template <
class E>
inline void
3283 template <
class E>
inline void
3289 template <
class E>
inline void
3295 template <
class E>
inline void
3302 template <
class E>
inline void
3304 const int nr = v.
nrow();
3305 for (
int i=0; i < nr; ++i) {
3306 if (i != 0) o << std::endl;
3312 template <
class E>
inline void
3318 template <
class E>
inline void
3324 template <
class E>
inline bool
3326 for (
int i=0; i < v.size(); ++i)
3332 template <
class E>
inline bool
3334 if (!v.isResizeable())
3340 for (
int i=0; i<a.
size(); ++i)
3347 template <
class E>
inline bool
3350 return readUnformatted<E>(in, vt); }
3354 template <
class E>
inline bool
3357 return readUnformatted<E>(in, vt); }
3363 template <
class E>
inline bool
3365 for (
int row=0; row < v.nrow(); ++row) {
3367 if (!readUnformatted<E>(in, oneRow))
return false;
3376 template <
class E>
inline bool
3383 template <
class E>
inline bool
3386 "SimTK::readUnformatted(istream, Matrix) is not implemented; try"
3387 " SimTK::fillUnformatted(istream, Matrix) instead.");
3397 template <
class T>
inline std::ostream&
3398 operator<<(std::ostream& o, const VectorBase<T>& v)
3402 for (
int i=1; i < v.size(); ++i) o <<
" " << v[i];
3413 template <
class T>
inline std::ostream&
3414 operator<<(std::ostream& o, const RowVectorBase<T>& v)
3418 for (
int i=1; i < v.size(); ++i) o <<
" " << v[i];
3430 template <
class T>
inline std::ostream&
3431 operator<<(std::ostream& o, const MatrixBase<T>& m) {
3432 for (
int i=0;i<m.nrow();++i)
3433 o << std::endl << m[i];
3434 if (m.nrow()) o << std::endl;
3470 template <
class T>
static inline
3472 {
return readVectorFromStreamHelper<T>(in,
false , out); }
3500 template <
class T>
static inline
3502 {
return readVectorFromStreamHelper<T>(in,
true , out); }
3508 template <
class T>
static inline
3510 {
return readVectorFromStreamHelper<T>(in,
true , out); }
3522 template <
class T>
inline
3524 {
return readVectorFromStream<T>(in, out); }
3533 template <
class T>
inline
3535 {
return fillVectorViewFromStream<T>(in, out); }
3588 template <
class ELT,
class VECTOR_CLASS>
3596 VectorIterator(VECTOR_CLASS& vector, ptrdiff_t index) : vector(vector), index(index) {
3601 vector = iter.vector;
3606 assert (index >= 0 && index < vector.size());
3607 return vector[(int)index];
3610 assert (i >= 0 && i < vector.size());
3611 return vector[(int)i];
3614 assert (index < vector.size());
3619 assert (index < vector.size());
3636 return (index < iter.index);
3639 return (index > iter.index);
3642 return (index <= iter.index);
3645 return (index >= iter.index);
3648 return (index - iter.index);
3657 return (index == iter.index);
3660 return (index != iter.index);
3663 VECTOR_CLASS& vector;
3669 #endif //SimTK_SIMMATRIX_BIGMATRIX_H_
Here we define class MatrixHelper<S>, the scalar-type templatized helper class for the more general...
Definition: MatrixHelper.h:79
VectorView_< ELT > operator()(int j) const
Definition: BigMatrix.h:746
Vector_< Complex > ComplexVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3544
void elementwiseDivide(const VectorBase< EE > &v, typename EltResult< EE >::Dvd &out) const
Definition: BigMatrix.h:1375
RowVectorBase(int n=0)
Default constructor makes a 1x0 matrix locked at 1 row; you can provide an initial allocation if you ...
Definition: BigMatrix.h:1518
void unlockShape()
Definition: BigMatrix.h:966
CNT< E >::Precision EPrecision
Definition: BigMatrix.h:245
VectorBase & operator-=(const VectorBase &r)
Definition: BigMatrix.h:1163
Inertia_< P > operator/(const Inertia_< P > &i, const P &r)
Divide an inertia matrix by a scalar.
Definition: MassProperties.h:616
VectorIterator< ELT, VectorBase< ELT > > begin()
Definition: BigMatrix.h:1473
RowVectorBase & operator+=(const RowVectorBase< EE > &b)
Definition: BigMatrix.h:1602
bool operator!=(VectorIterator iter) const
Definition: BigMatrix.h:3659
PhiMatrixTranspose transpose(const PhiMatrix &phi)
Definition: SpatialAlgebra.h:720
MatrixBase & setToNaN()
Definition: BigMatrix.h:735
EltResult< EE >::Dvd elementwiseDivide(const RowVectorBase< EE > &v) const
Definition: BigMatrix.h:1657
Vector_ & operator-=(const ELT &b)
Definition: BigMatrix.h:2121
DeadMatrixView_(MatrixHelper< S > &h)
Definition: BigMatrix.h:1854
VectorView_(const VectorView_ &v)
Definition: BigMatrix.h:2020
MatrixView_< ELT > operator()(int i, int j, int m, int n)
Definition: BigMatrix.h:755
VectorBase & operator/=(const StdNumber &t)
Definition: BigMatrix.h:1161
RowVector_(const RowVector_ &src)
Definition: BigMatrix.h:2220
RowVectorBase & elementwiseMultiplyFromLeftInPlace(const RowVectorBase< EE > &r)
Definition: BigMatrix.h:1635
K::ScalarNormSq ScalarNormSq
Definition: CompositeNumericalTypes.h:166
Vector_< ELT > & updAsVector()
Definition: BigMatrix.h:980
const VectorView_< ELT > & getAsVectorView() const
Definition: BigMatrix.h:974
void elementwiseDivide(const RowVectorBase< EE > &v, typename EltResult< EE >::Dvd &out) const
Definition: BigMatrix.h:1655
const MatrixCharacter & getMatrixCharacter() const
Definition: BigMatrix.h:271
MatrixBase< ESqTHerm > TSqTHerm
Definition: BigMatrix.h:268
MatrixBase(const MatrixCommitment &commitment, int m, int n, const ELT *cppInitialValuesByRow)
Initializing constructor with the initially-allocated elements initialized from a C++ array of elemen...
Definition: BigMatrix.h:390
EScalarNormSq ScalarNormSq
Definition: BigMatrix.h:252
Matrix_ & operator*=(const StdNumber &t)
Definition: BigMatrix.h:1966
RowVectorView_< fComplex > fComplexRowVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3566
#define SimTK_SIZECHECK(sz, maxsz, where)
Definition: ExceptionMacros.h:146
VectorView_ & operator-=(const ELT &b)
Definition: BigMatrix.h:2046
RowVector_(int n)
Definition: BigMatrix.h:2233
const TNeg & negate() const
Definition: BigMatrix.h:938
K::TReal TReal
Definition: CompositeNumericalTypes.h:141
Here we declare the detailed interface to the Simmatrix classes.
void clear()
Definition: BigMatrix.h:1748
RowVectorBase(const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a read-only view of the source data.
Definition: BigMatrix.h:1571
THerm updTranspose()
Definition: BigMatrix.h:1451
VectorView_< Real > VectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3548
MatrixBase & copyAssign(const MatrixBase &b)
Copy assignment is a deep copy but behavior depends on type of lhs: if view, rhs must match...
Definition: BigMatrix.h:348
void resize(int m, int n)
DeadMatrixView_ & operator*=(const StdNumber &t)
Definition: BigMatrix.h:1866
MatrixBase< EStandard > TStandard
Definition: BigMatrix.h:264
CNT< E >::TNormalize ENormalize
Definition: BigMatrix.h:238
RowVectorView_< ELT > operator()(int j, int n) const
Definition: BigMatrix.h:1711
Vector_ & operator=(const VectorBase< EE > &m)
Definition: BigMatrix.h:2111
void writeUnformatted(std::ostream &o, const VectorBase< E > &v)
Specialize for VectorBase<E> to delegate to element type E, with spaces separating the elements...
Definition: BigMatrix.h:3261
RS is total spacing between rows in memory (default 1)
Definition: SymMat.h:71
const TNeg & negate() const
Definition: BigMatrix.h:1971
MatrixView_ & operator=(const MatrixView_ &m)
Definition: BigMatrix.h:1795
DeadMatrixView_ & operator=(const Base &m)
Definition: BigMatrix.h:1848
VectorIterator & operator=(const VectorIterator &iter)
Definition: BigMatrix.h:3600
const VectorBase< ELT > & getAsVectorBase() const
Definition: BigMatrix.h:982
This is the Vector class intended to appear in user code.
Definition: BigMatrix.h:186
RowVectorBase(const TNeg &source)
Implicit conversion from compatible row vector with negated elements.
Definition: BigMatrix.h:1526
CNT< E >::TImag EImag
Definition: BigMatrix.h:230
This is a dataless rehash of the MatrixBase class to specialize it for RowVectors.
Definition: BigMatrix.h:177
MatrixView_< Real > MatrixView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3576
const MatrixCommitment & getCharacterCommitment() const
Definition: BigMatrix.h:270
Matrix_< fComplex > fComplexMatrix
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3573
VectorBase(const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::DeepCopy &d)
Construct a new owner vector initialized with the data from the source.
Definition: BigMatrix.h:1138
RowVectorView_< ELT > operator()(int j, int n)
Definition: BigMatrix.h:1712
VectorBase & operator=(const VectorBase< EE > &b)
Definition: BigMatrix.h:1166
RowVectorView_(MatrixHelper< S > &h)
Definition: BigMatrix.h:2176
Matrix_ & operator+=(const ELT &r)
Definition: BigMatrix.h:1968
DeadMatrixView_(const Base &m)
Definition: BigMatrix.h:1847
void resizeKeep(int m, int n)
RowVectorBase< EE >::template EltResult< ELT >::Dvd elementwiseDivideFromLeft(const RowVectorBase< EE > &v) const
Definition: BigMatrix.h:1671
RowVectorBase< EE >::template EltResult< ELT >::Mul elementwiseMultiplyFromLeft(const RowVectorBase< EE > &v) const
Definition: BigMatrix.h:1646
void elementwiseMultiplyFromLeft(const RowVectorBase< EE > &v, typename RowVectorBase< EE >::template EltResult< ELT >::Mul &out) const
Definition: BigMatrix.h:1638
MatrixHelper & copyAssign(const MatrixHelper &source)
DeadMatrixView_ & operator/=(const StdNumber &t)
Definition: BigMatrix.h:1867
std::istream & operator>>(std::istream &in, VectorView_< T > &out)
Read a (fixed size n) VectorView_<T> from a stream as a sequence of space- or comma-separated values ...
Definition: BigMatrix.h:3534
RowVectorBase & operator=(const ELT &t)
Fill current allocation with copies of element.
Definition: BigMatrix.h:1612
THerm operator~() const
Definition: BigMatrix.h:1731
Definition: BigMatrix.h:192
Matrix_(const Base &v)
Definition: BigMatrix.h:1925
VectorView_(MatrixHelper< S > &h)
Definition: BigMatrix.h:2030
EltResult< EE >::Mul colScale(const VectorBase< EE > &c) const
Definition: BigMatrix.h:562
CNT< E >::TNeg ENeg
Definition: BigMatrix.h:227
K::TSqrt TSqrt
Definition: CompositeNumericalTypes.h:154
VectorBase< ELT > & updAsVectorBase()
Definition: BigMatrix.h:984
bool readUnformatted(std::istream &in, Array_< T, X > &v)
Specialization of readUnformatted() for variable-length Array_<T,X>; continues reading whitespace-sep...
Definition: Array.h:3379
Vector_ & operator+=(const VectorBase< EE > &m)
Definition: BigMatrix.h:2113
RowVector_< double > dRowVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3557
MatrixHelper< Scalar > & updHelper()
Definition: BigMatrix.h:1042
MatrixBase & elementwiseSubtractScalarInPlace(const S &s)
Set M(i,j)-=s for every element of M and some value s.
CNT< E >::TStandard EStandard
Definition: BigMatrix.h:236
Definition: BigMatrix.h:280
std::random_access_iterator_tag iterator_category
Definition: BigMatrix.h:3595
static TSqrt sqrt(const K &t)
Definition: CompositeNumericalTypes.h:239
void commitTo(const MatrixCommitment &mc)
Change the handle commitment for this matrix handle; only allowed if the handle is currently clear...
Definition: BigMatrix.h:275
CNT< E >::THerm EHerm
Definition: BigMatrix.h:232
#define SimTK_ASSERT_ALWAYS(cond, msg)
Definition: ExceptionMacros.h:349
VectorBase & operator=(const VectorBase &b)
Copy assignment is deep copy but behavior depends on type of lhs: if view, rhs must match...
Definition: BigMatrix.h:1153
THerm operator~()
Definition: BigMatrix.h:1732
ScalarNormSq normSqr() const
This is the scalar Frobenius norm, and its square.
Definition: BigMatrix.h:899
RowVectorView_< ELT > row(int i) const
Definition: BigMatrix.h:2350
Matrix_ & operator=(const ELT &v)
Definition: BigMatrix.h:1957
VectorView_ & operator+=(const VectorBase< EE > &m)
Definition: BigMatrix.h:2038
const MatrixCharacter & getMatrixCharacter() const
MatrixBase< typename CNT< E >::TInvert > elementwiseInvert() const
Definition: BigMatrix.h:604
K::Scalar Scalar
Definition: CompositeNumericalTypes.h:160
Matrix_< Real > Matrix
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3569
Vector_(int m, const S *cppData, bool)
Construct a Vector which uses borrowed space with assumed element-to-element stride equal to the C++ ...
Definition: BigMatrix.h:2093
void elementwiseDivide(const MatrixBase< EE > &, typename EltResult< EE >::Dvd &) const
RowVectorView_< float > fRowVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3563
MatrixView_(MatrixHelperRep< S > *hrep)
Definition: BigMatrix.h:1784
A MatrixCharacter is a set containing a value for each of the matrix characteristics except element t...
Definition: MatrixCharacteristics.h:603
void set(int i, const ELT &value)
Variant of operator[] that's scripting friendly to set ith entry.
Definition: BigMatrix.h:2133
void colScale(const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition: BigMatrix.h:1620
K::TNormalize TNormalize
Definition: CompositeNumericalTypes.h:158
VectorIterator operator-(ptrdiff_t n) const
Definition: BigMatrix.h:3650
bool operator<(VectorIterator iter) const
Definition: BigMatrix.h:3635
TStandard standardize() const
Return a Matrix of the same shape and contents as this one but with the element type converted to one...
Definition: BigMatrix.h:887
RowVectorView_< dComplex > dComplexRowVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3567
MatrixView_ & operator/=(const StdNumber &t)
Definition: BigMatrix.h:1818
MatrixBase()
The default constructor builds a 0x0 matrix managed by a helper that understands how many scalars the...
Definition: BigMatrix.h:312
Matrix_ & operator-=(const ELT &r)
Definition: BigMatrix.h:1969
VectorIterator(VECTOR_CLASS &vector, ptrdiff_t index)
Definition: BigMatrix.h:3596
VectorView_< Complex > ComplexVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3551
CNT< E >::TComplex EComplex
Definition: BigMatrix.h:231
MatrixBase & elementwiseDivideFromLeftInPlace(const MatrixBase< EE > &)
M(i,j) = R(i,j) / M(i,j); R must have same dimensions as this.
MatrixBase & rowAndColScaleInPlace(const VectorBase< ER > &r, const VectorBase< EC > &c)
M = diag(r) * M * diag(c); r must have nrow() elements; must have ncol() elements.
EAbs weightedNormInf(const VectorBase< EE > &w, int *worstOne=0) const
Return the weighted infinity norm (max absolute value) WInf of a Vector of scalars, with optional return of the index of the weighted element of largest absolute value.
Definition: BigMatrix.h:1299
MatrixView_ & operator-=(const ELT &r)
Definition: BigMatrix.h:1820
VectorView_(MatrixHelperRep< S > *hrep)
Definition: BigMatrix.h:2015
MatrixBase & elementwiseMultiplyFromLeftInPlace(const MatrixBase< EE > &)
M(i,j) = R(i,j) * M(i,j); R must have same dimensions as this.
const TNeg & operator-() const
Definition: BigMatrix.h:1463
Vector_(int m)
Definition: BigMatrix.h:2085
MatrixBase & elementwiseAssign(const S &s)
Set M(i,j)=s for every element of M and some value s.
MatrixView_< EHerm > operator~()
Definition: BigMatrix.h:763
Vector_ & operator+=(const ELT &b)
Definition: BigMatrix.h:2120
void replaceContiguousScalarData(const Scalar *newData, ptrdiff_t length)
Definition: BigMatrix.h:1027
Matrix_ & operator=(const Matrix_ &src)
Definition: BigMatrix.h:1919
VectorView_< ELT > updCol(int j)
Definition: BigMatrix.h:2341
int size() const
Definition: BigMatrix.h:1411
MatrixBase & operator/=(const StdNumber &t)
Definition: BigMatrix.h:442
void writeUnformatted(std::ostream &o, const Vector_< E > &v)
Raw serialization of Vector_<E>; same as VectorBase<E>.
Definition: BigMatrix.h:3277
CNT< ScalarNormSq >::TSqrt normRMS() const
We only allow RMS norm if the elements are scalars.
Definition: BigMatrix.h:908
void replaceContiguousScalarData(Scalar *newData, ptrdiff_t length, bool takeOwnership)
Definition: BigMatrix.h:1024
MatrixBase & resizeKeep(int m, int n)
Change the size of this matrix, retaining as much of the old data as will fit.
Definition: BigMatrix.h:956
VectorView_< ELT > operator()(int i, int m) const
Definition: BigMatrix.h:1430
MatrixView_< dComplex > dComplexMatrixView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3581
Scalar * updContiguousScalarData()
Definition: BigMatrix.h:1021
VectorBase< typename CNT< ELT >::template Result< P >::Add > Add
Definition: BigMatrix.h:1147
MatrixBase< EHerm > THerm
Definition: BigMatrix.h:260
K::TImag TImag
Definition: CompositeNumericalTypes.h:142
EltResult< EE >::Mul elementwiseMultiply(const VectorBase< EE > &v) const
Definition: BigMatrix.h:1351
CNT< E >::Number ENumber
Definition: BigMatrix.h:243
Definition: Exception.h:297
RowVectorView_ & operator=(const RowVectorView_ &r)
Definition: BigMatrix.h:2170
RowVectorView_< ELT > updRow(int i)
Definition: BigMatrix.h:2359
ELT & updElt(int i, int j)
Definition: BigMatrix.h:833
ELT E
Definition: BigMatrix.h:226
int getNScalarsPerElement() const
This is the number of consecutive scalars used to represent one element of type ELT.
Definition: BigMatrix.h:1007
VectorView_ & operator-=(const VectorBase< EE > &m)
Definition: BigMatrix.h:2040
RowVectorBase(MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a writable view into the source data.
Definition: BigMatrix.h:1568
ptrdiff_t getContiguousScalarDataLength() const
Definition: BigMatrix.h:1015
int ncol() const
Definition: BigMatrix.h:1417
MatrixView_ & operator=(const ELT &e)
Definition: BigMatrix.h:1808
MatrixBase & viewAssign(const MatrixBase &src)
View assignment is a shallow copy, meaning that we disconnect the MatrixBase from whatever it used to...
Definition: BigMatrix.h:363
TNeg & operator-()
Definition: BigMatrix.h:942
RowVector_(int n, const ELT *cppInitialValues)
Definition: BigMatrix.h:2234
DeadMatrixView_ & operator=(const Matrix_< ELT > &v)
Definition: BigMatrix.h:1856
Matrix_(const Matrix_ &src)
Definition: BigMatrix.h:1915
VectorBase< typename CNT< ELT >::template Result< P >::Mul > Mul
Definition: BigMatrix.h:1145
bool fillUnformatted(std::istream &in, Matrix_< E > &v)
Read in new values for a Matrix without changing its size, from a stream of whitespace-separated toke...
Definition: BigMatrix.h:3377
Definition: BigMatrix.h:185
EltResult< S >::Sub elementwiseSubtractScalar(const S &s) const
Definition: BigMatrix.h:644
EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul rowAndColScale(const VectorBase< ER > &r, const VectorBase< EC > &c) const
Definition: BigMatrix.h:579
MatrixBase(const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, const Scalar *data)
Construct a read-only view of pre-existing data.
Definition: BigMatrix.h:408
MatrixBase(const MatrixCommitment &commitment, MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow)
Definition: BigMatrix.h:423
void elementwiseMultiply(const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition: BigMatrix.h:1349
size_type size() const
Return the current number of elements stored in this array.
Definition: Array.h:2014
void elementwiseMultiplyFromLeft(const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Mul &) const
Definition: BigMatrix.h:2564
This is a MatrixView_ with the additional property that we are about to delete it.
Definition: BigMatrix.h:180
VectorBase< EE >::template EltResult< ELT >::Mul elementwiseMultiplyFromLeft(const VectorBase< EE > &v) const
Definition: BigMatrix.h:1365
void elementwiseDivideFromLeft(const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Dvd &) const
Definition: BigMatrix.h:2613
VectorView_< ELT > operator()(int j)
Definition: BigMatrix.h:747
EltResult< EE >::Mul elementwiseMultiply(const RowVectorBase< EE > &v) const
Definition: BigMatrix.h:1631
MatrixBase(const MatrixCommitment &commitment, int m, int n)
This constructor takes a handle commitment and allocates the default matrix for that kind of commitme...
Definition: BigMatrix.h:332
RowVectorBase & operator-=(const RowVectorBase &r)
Definition: BigMatrix.h:1598
void colSum(int j, S *eltp) const
Vector_< double > dVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3543
void swapOwnedContiguousData(S *newData, ptrdiff_t length, S *&oldData)
void writeUnformatted(std::ostream &o, const VectorView_< E > &v)
Raw serialization of VectorView_<E>; same as VectorBase<E>.
Definition: BigMatrix.h:3271
MatrixBase & scalarMultiplyInPlace(const S &)
Set M(i,j) = M(i,j)*S for some "scalar" S.
void elementwiseMultiplyFromLeft(const VectorBase< EE > &v, typename VectorBase< EE >::template EltResult< ELT >::Mul &out) const
Definition: BigMatrix.h:1358
THerm transpose() const
Definition: BigMatrix.h:1728
VectorView_ & operator*=(const StdNumber &t)
Definition: BigMatrix.h:2043
Vector_< dComplex > dComplexVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3546
RowVectorView_ & operator+=(const RowVectorBase< EE > &m)
Definition: BigMatrix.h:2184
VectorView_< double > dVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3550
CNT< E >::TWithoutNegator EWithoutNegator
Definition: BigMatrix.h:228
RowVector_< fComplex > fComplexRowVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3559
MatrixBase & operator-=(const MatrixBase &r)
Definition: BigMatrix.h:444
MatrixBase & operator*=(const StdNumber &t)
Definition: BigMatrix.h:441
void scaleBy(const StdNumber &)
Vector_< float > fVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3542
Matrix_< ELT > & updAsMatrix()
Definition: BigMatrix.h:972
static TStandard standardize(const K &t)
Definition: CompositeNumericalTypes.h:241
Vector_ & operator*=(const StdNumber &t)
Definition: BigMatrix.h:2118
CNT< ScalarNormSq >::TSqrt norm() const
Definition: BigMatrix.h:902
void matmul(const StdNumber &beta, const StdNumber &alpha, const MatrixHelper< SA > &A, const MatrixHelper< SB > &B)
VectorView_< float > fVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3549
void getAnyElt(int i, int j, ELT &value) const
This returns a copy of the element value for any position in the logical matrix, regardless of whethe...
Definition: BigMatrix.h:842
RowVector_(int n, const ELT &initialValue)
Definition: BigMatrix.h:2235
RowVectorBase & operator+=(const RowVectorBase &r)
Definition: BigMatrix.h:1597
RowVectorView_ & operator=(const RowVectorBase< EE > &m)
Definition: BigMatrix.h:2182
TNeg & operator-()
Definition: BigMatrix.h:1464
DeadMatrixView_ & operator=(const ELT &e)
Definition: BigMatrix.h:1857
std::istream & operator>>(std::istream &in, Vector_< T > &out)
Read Vector_<T> from a stream as a sequence of space- or comma-separated values of type T...
Definition: BigMatrix.h:3523
VectorBase & operator-=(const VectorBase< EE > &b)
Definition: BigMatrix.h:1170
VectorBase & operator+=(const VectorBase &r)
Definition: BigMatrix.h:1162
ELT & operator()(int j)
Definition: BigMatrix.h:1708
unsigned char square(unsigned char u)
Definition: Scalar.h:351
VectorView_< ELT > updIndex(const Array_< int > &indices)
Definition: BigMatrix.h:1440
void elementwiseDivideFromLeft(const VectorBase< EE > &v, typename VectorBase< EE >::template EltResult< ELT >::Dvd &out) const
Definition: BigMatrix.h:1384
Definition: BigMatrix.h:1580
RowVectorBase & operator=(const RowVectorBase< EE > &b)
Definition: BigMatrix.h:1600
void abs(TAbs &mabs) const
abs() is elementwise absolute value; that is, the return value has the same dimension as this Matrix ...
Definition: BigMatrix.h:864
const Matrix_< ELT > & getAsMatrix() const
Definition: BigMatrix.h:971
VectorBase & operator+=(const VectorBase< EE > &b)
Definition: BigMatrix.h:1168
const RowVector_< ELT > & getAsRowVector() const
Definition: BigMatrix.h:991
This class is identical to a RowVector_; it is used only to manage the C++ rules for when copy constr...
Definition: BigMatrix.h:189
Matrix_< dComplex > dComplexMatrix
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3574
CNT< E >::TInvert EInvert
Definition: BigMatrix.h:237
RowVectorView_< ELT > operator[](int i)
Definition: BigMatrix.h:745
void set(int i, int j, const ELT &value)
Variant of indexing operator that's scripting friendly to set entry (i, j)
Definition: BigMatrix.h:1987
RowVector_(int n, S *cppData, bool)
Definition: BigMatrix.h:2242
Vector_< fComplex > fComplexVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3545
VectorBase(const VectorBase &source)
Copy constructor is a deep copy (not appropriate for views!).
Definition: BigMatrix.h:1087
Vector_(int m, S *cppData, bool)
Definition: BigMatrix.h:2094
void writeUnformatted(std::ostream &o, const RowVector_< E > &v)
Raw serialization of RowVector_<E>; same as Vector_<E>.
Definition: BigMatrix.h:3296
Matrix_()
Definition: BigMatrix.h:1911
MatrixBase< typename CNT< E >::template Result< P >::Sub > Sub
Definition: BigMatrix.h:284
RowVectorBase(const RowVectorBase &source)
Copy constructor is a deep copy (not appropriate for views!).
Definition: BigMatrix.h:1523
ELEM sum(const VectorBase< ELEM > &v)
Definition: VectorMath.h:147
VectorIterator operator+(ptrdiff_t n) const
Definition: BigMatrix.h:3653
RowVector_< ELT > & updAsRowVector()
Definition: BigMatrix.h:993
VectorBase & elementwiseDivideFromLeftInPlace(const VectorBase< EE > &r)
Definition: BigMatrix.h:1381
K::TSqTHerm TSqTHerm
Definition: CompositeNumericalTypes.h:147
MatrixBase< EComplex > TComplex
Definition: BigMatrix.h:259
VectorBase< typename CNT< ELT >::template Result< P >::Dvd > Dvd
Definition: BigMatrix.h:1146
Matrix_ & operator=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1959
void copyInByRowsFromCpp(const S *elts)
Vector_ & operator-=(const VectorBase< EE > &m)
Definition: BigMatrix.h:2115
const TNeg & operator-() const
Definition: BigMatrix.h:1741
VectorBase(const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a read-only view of the source data.
Definition: BigMatrix.h:1135
RowVector_ & operator+=(const ELT &b)
Definition: BigMatrix.h:2268
void fillWith(const S *eltp)
VectorBase(const TNeg &source)
Implicit conversion from compatible vector with negated elements.
Definition: BigMatrix.h:1090
RowVectorBase(int n, const ELT &initialValue)
Construct an owner row vector of length n, with each element initialized to the given value...
Definition: BigMatrix.h:1530
CNT< E >::StdNumber EStdNumber
Definition: BigMatrix.h:244
MatrixView_< EHerm > transpose() const
Definition: BigMatrix.h:2302
MatrixView_< ELT > updBlock(int i, int j, int m, int n)
Definition: BigMatrix.h:2291
VectorBase & rowScaleInPlace(const VectorBase< EE > &v)
There's only one column here so it's a bit weird to use rowScale rather than elementwiseMultiply, but there's nothing really wrong with it.
Definition: BigMatrix.h:1183
This is a fixed length column vector designed for no-overhead inline computation. ...
Definition: Vec.h:131
DeadMatrixView_ & operator+=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1861
void writeUnformatted(std::ostream &o, const MatrixView_< E > &v)
Raw serialization of MatrixView_<E>; same as MatrixBase<E>.
Definition: BigMatrix.h:3313
MatrixView_ & operator+=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1812
Vector_(const Base &src)
Definition: BigMatrix.h:2075
This is an iterator for iterating over the elements of a Vector.
Definition: BigMatrix.h:194
Vector_(const Vec< M, ELT > &v)
Convert a Vec to a Vector_.
Definition: BigMatrix.h:2104
EltResult< S >::Add elementwiseAddScalar(const S &s) const
Definition: BigMatrix.h:624
THerm operator~()
Definition: BigMatrix.h:1454
VectorView_< ELT > operator()(const Array_< int > &indices)
Definition: BigMatrix.h:1447
VectorView_< ELT > diag()
This non-const version of diag() is an alternate name for updDiag() available for historical reasons...
Definition: BigMatrix.h:773
int nrow() const
Return the number of rows m in the logical shape of this matrix.
Definition: BigMatrix.h:288
void rowSum(int i, S *eltp) const
Definition: BigMatrix.h:182
This is the default commitment for a row vector.
Definition: MatrixCharacteristics.h:1010
ELT sum() const
Definition: BigMatrix.h:1472
RowVector_< ELT > colSum() const
Form the column sums of this matrix, returned as a RowVector.
Definition: BigMatrix.h:917
MatrixBase< EImag > TImag
Definition: BigMatrix.h:258
void elementwiseSubtractScalar(const S &s, typename EltResult< S >::Sub &) const
K::Precision Precision
Definition: CompositeNumericalTypes.h:164
RowVectorBase(MatrixHelperRep< Scalar > *hrep)
Definition: BigMatrix.h:1760
Matrix_(const MatrixCommitment &mc)
Definition: BigMatrix.h:1912
RowVector_ & operator=(const ELT &v)
Definition: BigMatrix.h:2257
VectorView_< ELT > operator()(const Array_< int > &indices) const
Definition: BigMatrix.h:1446
VectorView_ & operator=(const Base &b)
Definition: BigMatrix.h:2032
TNeg & updNegate()
Definition: BigMatrix.h:939
RowVector_ & operator-=(const ELT &b)
Definition: BigMatrix.h:2269
VectorIterator operator++(int)
Definition: BigMatrix.h:3618
Vector_< ELT > rowSum() const
Form the row sums of this matrix, returned as a Vector.
Definition: BigMatrix.h:928
Vector_< Real > Vector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3541
RowVectorView_ & operator=(const Base &b)
Definition: BigMatrix.h:2178
void writeUnformatted(std::ostream &o, const RowVectorView_< E > &v)
Raw serialization of RowVectorView_<E>; same as VectorView_<E>.
Definition: BigMatrix.h:3290
MatrixBase< E > TPosTrans
Definition: BigMatrix.h:261
VectorBase & elementwiseMultiplyFromLeftInPlace(const VectorBase< EE > &r)
Definition: BigMatrix.h:1355
RowVectorBase & elementwiseMultiplyInPlace(const RowVectorBase< EE > &r)
Definition: BigMatrix.h:1627
RowVector_ & operator*=(const StdNumber &t)
Definition: BigMatrix.h:2266
This class is identical to a Matrix_; it is used only to manage the C++ rules for when copy construct...
Definition: BigMatrix.h:179
void dump(const char *msg=0) const
Matlab-compatible debug output.
Definition: BigMatrix.h:795
Inertia_< P > operator*(const Inertia_< P > &i, const P &r)
Multiply an inertia matrix by a scalar.
Definition: MassProperties.h:588
ScalarNormSq scalarNormSqr() const
Scalar norm square is sum( squares of all scalars ).
Definition: BigMatrix.h:850
RowVector_< ELT > sum() const
Alternate name for colSum(); behaves like the Matlab function sum().
Definition: BigMatrix.h:925
EltResult< EE >::Mul elementwiseMultiply(const MatrixBase< EE > &m) const
Definition: BigMatrix.h:681
void elementwiseDivide(const Row< 1, E1, S1 > &r1, const Row< 1, E2, S2 > &r2, Row< 1, typename CNT< E1 >::template Result< E2 >::Dvd > &result)
Definition: Row.h:90
RowVectorBase< typename CNT< ELT >::template Result< P >::Sub > Sub
Definition: BigMatrix.h:1584
MatrixBase & elementwiseAssign(int s)
Overloaded to allow an integer argument, which is converted to Real.
Definition: BigMatrix.h:596
VectorIterator operator--()
Definition: BigMatrix.h:3624
RowVectorBase< typename CNT< ELT >::template Result< P >::Mul > Mul
Definition: BigMatrix.h:1581
RowVectorView_ & operator-=(const ELT &b)
Definition: BigMatrix.h:2192
DeadMatrixView_ & operator=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1859
RowVector_(int n, int stride, const S *data, bool)
Borrowed-space construction with explicit stride supplied as "number of scalars between elements"...
Definition: BigMatrix.h:2247
MatrixView_< fComplex > fComplexMatrixView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3580
const ELT & operator[](int j) const
Definition: BigMatrix.h:1705
K::TInvert TInvert
Definition: CompositeNumericalTypes.h:157
MatrixBase & scalarAddInPlace(const S &s)
Add a scalar to M's diagonal.
Definition: BigMatrix.h:486
const RowVectorBase< ELT > & getAsRowVectorBase() const
Definition: BigMatrix.h:995
MatrixView_< ELT > block(int i, int j, int m, int n) const
Definition: BigMatrix.h:2280
CNT< E >::TSqHermT ESqHermT
Definition: BigMatrix.h:239
MatrixView_< EHerm > updTranspose()
Definition: BigMatrix.h:2310
Matrix_(int m, int n, const ELT &initialValue)
Definition: BigMatrix.h:1939
EltResult< EE >::Mul rowScale(const VectorBase< EE > &v) const
Definition: BigMatrix.h:1187
VectorView_ & operator=(const ELT &v)
Definition: BigMatrix.h:2034
MatrixView_(const MatrixView_ &m)
Definition: BigMatrix.h:1789
RowVectorView_< ELT > updIndex(const Array_< int > &indices)
Definition: BigMatrix.h:1719
This is a user-includable header which includes everything needed to make use of SimMatrix Scalar cod...
VectorView_ & operator=(const VectorView_ &v)
Definition: BigMatrix.h:2024
EltResult< EE >::Mul colScale(const VectorBase< EE > &v) const
Definition: BigMatrix.h:1622
RowVector_ & operator/=(const StdNumber &t)
Definition: BigMatrix.h:2267
VectorBase(MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
Construct a writable view into the source data.
Definition: BigMatrix.h:1132
CNT< E >::TReal EReal
Definition: BigMatrix.h:229
VectorView_< ELT > updDiag()
Select main diagonal (of largest leading square if rectangular) and return it as a writable view of t...
Definition: BigMatrix.h:2325
Matrix_(int m, int n, int leadingDim, const S *data)
Definition: BigMatrix.h:1942
void subIn(const MatrixHelper &)
Vector_ & operator=(const ELT &v)
Definition: BigMatrix.h:2109
MatrixBase(const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, Scalar *data)
Construct a writable view of pre-existing data.
Definition: BigMatrix.h:415
VectorBase & resizeKeep(int m)
Definition: BigMatrix.h:1467
TNeg & operator-()
Definition: BigMatrix.h:1742
ENumber Number
Definition: BigMatrix.h:249
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
MatrixBase & scalarSubtractFromLeftInPlace(const S &s)
Set M(i,i) = S - M(i,i), M(i,j) = -M(i,j) for i!=j.
Definition: BigMatrix.h:502
MatrixBase< typename CNT< E >::template Result< P >::Add > Add
Definition: BigMatrix.h:283
RowVectorBase< ELT > & updAsRowVectorBase()
Definition: BigMatrix.h:997
RowVectorBase< typename CNT< ELT >::template Result< P >::Dvd > Dvd
Definition: BigMatrix.h:1582
RowVectorBase & colScaleInPlace(const VectorBase< EE > &v)
There's only one row here so it's a bit wierd to use colScale rather than elementwiseMultiply, but there's nothing really wrong with it.
Definition: BigMatrix.h:1618
VectorView_(const MatrixHelper< S > &h)
Definition: BigMatrix.h:2029
RowVectorBase & operator-=(const RowVectorBase< EE > &b)
Definition: BigMatrix.h:1604
MatrixBase(const TNeg &b)
Implicit conversion from matrix with negated elements (otherwise this is just like the copy construct...
Definition: BigMatrix.h:342
MatrixBase< typename CNT< E >::template Result< P >::Dvd > Dvd
Definition: BigMatrix.h:282
RowVectorView_(const RowVectorView_ &r)
Definition: BigMatrix.h:2166
TNeg & updNegate()
Definition: BigMatrix.h:1461
VectorBase & elementwiseDivideInPlace(const VectorBase< EE > &r)
Definition: BigMatrix.h:1373
RowVectorBase & resize(int n)
Definition: BigMatrix.h:1744
MatrixBase< E > T
Definition: BigMatrix.h:254
VectorIterator< ELT, RowVectorBase< ELT > > begin()
Definition: BigMatrix.h:1751
#define SimTK_THROW1(exc, a1)
Definition: Exception.h:311
void rowScale(const VectorBase< EE > &r, typename EltResult< EE >::Mul &out) const
Return type is a new matrix which will have the same dimensions as 'this' but will have element types...
TNeg & operator-()
Definition: BigMatrix.h:1975
RowVectorView_ & operator-=(const RowVectorBase< EE > &m)
Definition: BigMatrix.h:2186
Vector_ & operator=(const Vector_ &src)
Definition: BigMatrix.h:2080
VectorView_< ELT > index(const Array_< int > &indices) const
Definition: BigMatrix.h:1435
VectorBase(int m, int stride, Scalar *s)
Construct a writable view into existing data.
Definition: BigMatrix.h:1119
VectorIterator< ELT, RowVectorBase< ELT > > end()
Definition: BigMatrix.h:1754
MatrixBase< EInvert > TInvert
Definition: BigMatrix.h:265
RowVectorBase & elementwiseDivideInPlace(const RowVectorBase< EE > &r)
Definition: BigMatrix.h:1653
MatrixView_ & operator=(const Matrix_< ELT > &v)
Definition: BigMatrix.h:1807
int nrow() const
Definition: BigMatrix.h:1416
const ELT & getElt(int i, int j) const
Element selection for stored elements.
Definition: BigMatrix.h:832
MatrixBase< ENormalize > TNormalize
Definition: BigMatrix.h:266
CNT< E >::TPosTrans EPosTrans
Definition: BigMatrix.h:233
MatrixBase< EAbs > TAbs
Definition: BigMatrix.h:263
int nrow() const
Definition: BigMatrix.h:1695
RowVector_ & operator-=(const RowVectorBase< EE > &b)
Definition: BigMatrix.h:2263
const RowVectorBase & operator+() const
Definition: BigMatrix.h:1734
void lockShape()
Definition: BigMatrix.h:960
RowVectorBase & elementwiseDivideFromLeftInPlace(const RowVectorBase< EE > &r)
Definition: BigMatrix.h:1661
RowVectorBase & operator/=(const StdNumber &t)
Definition: BigMatrix.h:1596
K::TPosTrans TPosTrans
Definition: CompositeNumericalTypes.h:145
EStdNumber StdNumber
Definition: BigMatrix.h:250
MatrixHelperRep< S > * stealRep()
Definition: MatrixHelper.h:341
VectorIterator operator--(int)
Definition: BigMatrix.h:3629
RowVectorView_(const MatrixHelper< S > &h)
Definition: BigMatrix.h:2175
RowVectorView_< Real > RowVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3562
TInvert invert() const
Definition: BigMatrix.h:786
RowVector_ & operator=(const RowVector_ &src)
Definition: BigMatrix.h:2228
MatrixBase< EWithoutNegator > TWithoutNegator
Definition: BigMatrix.h:256
Definition: BigMatrix.h:306
void writeUnformatted(std::ostream &o, const Matrix_< E > &v)
Raw serialization of Vector_<E>; same as VectorBase<E>.
Definition: BigMatrix.h:3319
MatrixBase< EReal > TReal
Definition: BigMatrix.h:257
void elementwiseMultiply(const Row< 1, E1, S1 > &r1, const Row< 1, E2, S2 > &r2, Row< 1, typename CNT< E1 >::template Result< E2 >::Mul > &result)
Definition: Row.h:75
RowVector_()
Definition: BigMatrix.h:2216
bool isResizeable() const
Return true if either dimension of this Matrix is resizable.
Definition: BigMatrix.h:302
Here we declare the classes needed for managing the properties of matrices, which we call Matrix Char...
This file is the user-includeable header to be included in user programs to provide fixed-length Vec ...
EltResult< EE >::Mul rowScale(const VectorBase< EE > &r) const
Definition: BigMatrix.h:549
const TNeg & operator-() const
Definition: BigMatrix.h:941
const MatrixView_< ELT > & getAsMatrixView() const
Definition: BigMatrix.h:969
MatrixView_< double > dMatrixView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3578
MatrixBase & elementwiseInvertInPlace()
Set M(i,j) = M(i,j)^-1.
Definition: BigMatrix.h:2441
MatrixBase & rowScaleInPlace(const VectorBase< EE > &)
M = diag(r) * M; r must have nrow() elements.
int size() const
Definition: BigMatrix.h:1690
Vector_(const Vector_ &src)
Definition: BigMatrix.h:2072
MatrixHelper & writableViewAssign(MatrixHelper &source)
const Vector_< ELT > & getAsVector() const
Definition: BigMatrix.h:978
CNT< ScalarNormSq >::TSqrt weightedNormRMS(const VectorBase< EE > &w, int *worstOne=0) const
Return the weighted root-mean-square (WRMS) norm of a Vector of scalars, with optional return of the ...
Definition: BigMatrix.h:1231
RowVectorView_< Complex > ComplexRowVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3565
This is the Matrix class intended to appear in user code.
Definition: BigMatrix.h:181
MatrixView_(const MatrixHelper< S > &h)
Definition: BigMatrix.h:1804
int getPackedSizeofElement() const
This is like sizeof(ELT), but returning the number of bytes we use to store the element which may be ...
Definition: BigMatrix.h:1012
Matrix_< Complex > ComplexMatrix
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3572
ELT & operator()(int i)
Definition: BigMatrix.h:1427
CNT< E >::TSqTHerm ESqTHerm
Definition: BigMatrix.h:240
RowVectorBase & operator=(const RowVectorBase &b)
Copy assignment is deep copy but behavior depends on type of lhs: if view, rhs must match...
Definition: BigMatrix.h:1589
MatrixView_< EHerm > operator~() const
Definition: BigMatrix.h:762
Definition: BigMatrix.h:190
DeadMatrixView_(MatrixHelperRep< S > *hrep)
Definition: BigMatrix.h:1846
MatrixBase & elementwiseAddScalarInPlace(const S &s)
Set M(i,j)+=s for every element of M and some value s.
RowVectorView_< ELT > index(const Array_< int > &indices) const
Definition: BigMatrix.h:1715
MatrixBase & operator+=(const MatrixBase &r)
Definition: BigMatrix.h:443
Definition: BigMatrix.h:187
K::StdNumber StdNumber
Definition: CompositeNumericalTypes.h:163
ELT getAnyElt(int i, int j) const
Definition: BigMatrix.h:844
DeadMatrixView_ & operator-=(const ELT &r)
Definition: BigMatrix.h:1869
Matrix_(const BaseNeg &v)
Definition: BigMatrix.h:1929
const S * getElt(int i, int j) const
RowVectorBase< typename CNT< ELEM >::TAbs > abs(const RowVectorBase< ELEM > &v)
Definition: VectorMath.h:120
void colScale(const VectorBase< EE > &c, typename EltResult< EE >::Mul &out) const
MatrixBase & operator=(const MatrixBase< EE > &b)
Definition: BigMatrix.h:449
void elementwiseMultiply(const MatrixBase< EE > &, typename EltResult< EE >::Mul &) const
MatrixBase & setToZero()
Definition: BigMatrix.h:736
MatrixBase< S >::template EltResult< E >::Sub elementwiseSubtractFromScalar(const S &s) const
Definition: BigMatrix.h:667
MatrixBase(const MatrixCommitment &commitment, int m, int n, const ELT &initialValue)
Initializing constructor with all of the initially-allocated elements initialized to the same value...
Definition: BigMatrix.h:376
bool hasContiguousData() const
Matrix_(int m, int n)
Definition: BigMatrix.h:1935
THerm updTranspose()
Definition: BigMatrix.h:1729
void elementwiseAddScalar(const S &s, typename EltResult< S >::Add &) const
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
const RowVectorView_< ELT > & getAsRowVectorView() const
Definition: BigMatrix.h:987
RowVectorBase(int n, int stride, Scalar *s)
Construct a writable view into existing data.
Definition: BigMatrix.h:1555
Matrix_(int m, int n, const ELT *cppInitialValuesByRow)
Definition: BigMatrix.h:1937
ptrdiff_t operator-(VectorIterator iter) const
Definition: BigMatrix.h:3647
MatrixBase & operator-=(const MatrixBase< EE > &b)
Definition: BigMatrix.h:453
bool operator>=(VectorIterator iter) const
Definition: BigMatrix.h:3644
void invertInPlace()
Definition: BigMatrix.h:792
TAbs abs() const
Definition: BigMatrix.h:1421
Generic Row.
Definition: Row.h:118
void addIn(const MatrixHelper &)
DeadMatrixView_ & operator-=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1863
VectorIterator(const VectorIterator &iter)
Definition: BigMatrix.h:3598
Matrix_ & operator+=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1961
MatrixView_ & operator*=(const StdNumber &t)
Definition: BigMatrix.h:1817
MatrixBase(const MatrixCommitment &commitment)
This constructor takes a handle commitment and allocates the default matrix for that kind of commitme...
Definition: BigMatrix.h:324
static std::istream & fillVectorViewFromStream(std::istream &in, VectorView_< T > &out)
Read in a fixed number of elements from a stream into an VectorView.
Definition: BigMatrix.h:3509
MatrixView_< Complex > ComplexMatrixView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3579
CNT< E >::ScalarNormSq EScalarNormSq
Definition: BigMatrix.h:246
K T
Definition: CompositeNumericalTypes.h:138
Matrix_ & operator/=(const StdNumber &t)
Definition: BigMatrix.h:1967
EAbs normInf(int *worstOne=0) const
Return the infinity norm (max absolute value) of a Vector of scalars, with optional return of the ind...
Definition: BigMatrix.h:1266
bool operator>(VectorIterator iter) const
Definition: BigMatrix.h:3638
VectorView_< fComplex > fComplexVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3552
RowVectorView_ & operator*=(const StdNumber &t)
Definition: BigMatrix.h:2189
VectorBase(MatrixHelperRep< Scalar > *hrep)
Definition: BigMatrix.h:1482
MatrixBase & scalarDivideInPlace(const S &)
Set M(i,j) = M(i,j)/S for some "scalar" S.
MatrixBase< EE >::template EltResult< EE >::Dvd elementwiseDivideFromLeft(const MatrixBase< EE > &m) const
Definition: BigMatrix.h:727
VectorView_< ELT > diag() const
Select main diagonal (of largest leading square if rectangular) and return it as a read-only view of ...
Definition: BigMatrix.h:2318
RowVectorView_(MatrixHelperRep< S > *hrep)
Definition: BigMatrix.h:2161
VectorView_< ELT > operator()(int i, int m)
Definition: BigMatrix.h:1431
MatrixBase & operator=(const MatrixBase &b)
Definition: BigMatrix.h:352
VectorView_ & operator+=(const ELT &b)
Definition: BigMatrix.h:2045
MatrixBase(int m, int n)
This constructor allocates the default matrix a completely uncommitted matrix commitment, given particular initial dimensions.
Definition: BigMatrix.h:316
const MatrixHelper< Scalar > & getHelper() const
Definition: BigMatrix.h:1041
ptrdiff_t getContiguousDataLength() const
RowVector_(const Row< M, ELT > &v)
Convert a Row to a RowVector_.
Definition: BigMatrix.h:2252
void rowScale(const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition: BigMatrix.h:1185
RowVector_ & operator+=(const RowVectorBase< EE > &b)
Definition: BigMatrix.h:2261
VectorBase & operator=(const ELT &t)
Fill current allocation with copies of element.
Definition: BigMatrix.h:1177
void clear()
Definition: BigMatrix.h:1470
RowVectorView_ & operator+=(const ELT &b)
Definition: BigMatrix.h:2191
CNT< E >::TAbs EAbs
Definition: BigMatrix.h:235
ELT & operator[](int j)
Definition: BigMatrix.h:1706
ELT & operator[](ptrdiff_t i)
Definition: BigMatrix.h:3609
void getAnyElt(int i, int j, S *value) const
void writeUnformatted(std::ostream &o, const RowVectorBase< E > &v)
Specialize for RowVectorBase<E> to delegate to element type E, with spaces separating the elements; r...
Definition: BigMatrix.h:3284
VectorView_ & operator/=(const StdNumber &t)
Definition: BigMatrix.h:2044
K::TNeg TNeg
Definition: CompositeNumericalTypes.h:139
Matrix_< float > fMatrix
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3570
This is a dataless rehash of the MatrixBase class to specialize it for Vectors.
Definition: BigMatrix.h:176
void elementwiseMultiply(const RowVectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
Definition: BigMatrix.h:1629
MatrixBase & scalarDivideFromLeftInPlace(const S &)
Set M(i,j) = S/M(i,j) for some "scalar" S.
VectorBase(int m, int stride, const Scalar *s)
Construct a read-only view of existing data.
Definition: BigMatrix.h:1116
RowVector_(int n, const S *cppData, bool)
Construct a Vector which uses borrowed space with assumed element-to-element stride equal to the C++ ...
Definition: BigMatrix.h:2241
K::TStandard TStandard
Definition: CompositeNumericalTypes.h:156
#define SimTK_INDEXCHECK(ix, ub, where)
Definition: ExceptionMacros.h:145
MatrixView_(MatrixHelper< S > &h)
Definition: BigMatrix.h:1805
Definition: BigMatrix.h:305
K::TWithoutNegator TWithoutNegator
Definition: CompositeNumericalTypes.h:140
CNT< E >::Scalar EScalar
Definition: BigMatrix.h:242
const Scalar * getContiguousScalarData() const
Definition: BigMatrix.h:1018
RowVectorView_< ELT > operator[](int i) const
Definition: BigMatrix.h:744
RowVector_(int n, int stride, S *data, bool)
Definition: BigMatrix.h:2248
VectorIterator< ELT, VectorBase< ELT > > end()
Definition: BigMatrix.h:1476
RowVectorBase(int n, int stride, const Scalar *s)
Construct a read-only view of existing data.
Definition: BigMatrix.h:1552
RowVectors are much less common than Vectors.
Definition: BigMatrix.h:191
VectorBase< EE >::template EltResult< ELT >::Dvd elementwiseDivideFromLeft(const VectorBase< EE > &v) const
Definition: BigMatrix.h:1391
DeadMatrixView_ & operator+=(const ELT &r)
Definition: BigMatrix.h:1868
const TNeg & operator-() const
Definition: BigMatrix.h:1974
const ELT & operator[](int i) const
Definition: BigMatrix.h:1424
Vector_()
Definition: BigMatrix.h:2068
TNeg & updNegate()
Definition: BigMatrix.h:1972
MatrixView_ & operator=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1810
void commitTo(const MatrixCommitment &)
std::string toString() const
toString() returns a string representation of the Vector_.
Definition: BigMatrix.h:2125
static std::istream & readVectorFromStreamHelper(std::istream &in, bool isFixedSize, Vector_< T > &out)
Definition: BigMatrix.h:3058
A MatrixCommitment provides a set of acceptable matrix characteristics.
Definition: MatrixCharacteristics.h:837
ELT & operator*()
Definition: BigMatrix.h:3605
MatrixBase & matmul(const StdNumber &beta, const StdNumber &alpha, const MatrixBase< ELT_A > &A, const MatrixBase< ELT_B > &B)
Definition: BigMatrix.h:817
VectorView_< ELT > & updAsVectorView()
Definition: BigMatrix.h:976
void swapOwnedContiguousScalarData(Scalar *newData, ptrdiff_t length, Scalar *&oldData)
Definition: BigMatrix.h:1030
VectorView_ & operator=(const VectorBase< EE > &m)
Definition: BigMatrix.h:2036
const ELT & operator()(int i) const
Definition: BigMatrix.h:1426
MatrixBase< EE >::template EltResult< E >::Mul elementwiseMultiplyFromLeft(const MatrixBase< EE > &m) const
Definition: BigMatrix.h:697
RowVectorBase(const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::DeepCopy &d)
Construct a new owner vector initialized with the data from the source.
Definition: BigMatrix.h:1574
ELT sum() const
Definition: BigMatrix.h:1750
const ELT & operator()(int j) const
Definition: BigMatrix.h:1707
THerm operator~() const
Definition: BigMatrix.h:1453
void elementwiseDivideFromLeft(const RowVectorBase< EE > &v, typename RowVectorBase< EE >::template EltResult< ELT >::Dvd &out) const
Definition: BigMatrix.h:1665
bool operator==(VectorIterator iter) const
Definition: BigMatrix.h:3656
RowVectorView_< ELT > operator()(const Array_< int > &indices) const
Definition: BigMatrix.h:1724
void replaceContiguousData(S *newData, ptrdiff_t length, bool takeOwnership)
Vector_(const BaseNeg &src)
Definition: BigMatrix.h:2076
static std::istream & readVectorFromStream(std::istream &in, Vector_< T > &out)
Read in a Vector_<T> from a stream, as a sequence of space-separated or comma-separated values option...
Definition: BigMatrix.h:3471
MatrixBase(MatrixHelperRep< Scalar > *hrep)
Helper rep-stealing constructor.
Definition: BigMatrix.h:1038
Vector_ & operator/=(const StdNumber &t)
Definition: BigMatrix.h:2119
const VectorBase & operator+() const
Definition: BigMatrix.h:1456
ptrdiff_t nelt() const
Return the number of elements in the logical shape of this matrix.
Definition: BigMatrix.h:299
void elementwiseSubtractFromScalar(const S &, typename MatrixBase< S >::template EltResult< E >::Sub &) const
Definition: BigMatrix.h:2515
TAbs abs() const
abs() with the result as a function return.
Definition: BigMatrix.h:875
CoordinateDirection operator+(const CoordinateAxis &axis)
Create the positive direction along the given axis.
Definition: CoordinateAxis.h:390
VectorBase & resize(int m)
Definition: BigMatrix.h:1466
bool isResizeable() const
Definition: MatrixCharacteristics.h:930
bool operator<=(VectorIterator iter) const
Definition: BigMatrix.h:3641
MatrixView_ & operator+=(const ELT &r)
Definition: BigMatrix.h:1819
MatrixBase & elementwiseDivideInPlace(const MatrixBase< EE > &)
M(i,j) /= R(i,j); R must have same dimensions as this.
MatrixBase(const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow)
Definition: BigMatrix.h:427
This class represents a small matrix whose size is known at compile time, containing elements of any ...
Definition: Mat.h:51
RowVector_< float > fRowVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3556
K::TComplex TComplex
Definition: CompositeNumericalTypes.h:143
std::string toString() const
toString() returns a string representation of the Matrix_.
Definition: BigMatrix.h:1979
Variable-size 2d matrix of Composite Numerical Type (ELT) elements.
Definition: BigMatrix.h:175
ELT value_type
Definition: BigMatrix.h:3591
MatrixView_< float > fMatrixView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3577
K::Number Number
Definition: CompositeNumericalTypes.h:162
THerm transpose() const
Definition: BigMatrix.h:1450
MatrixBase & operator=(const ELT &t)
Matrix assignment to an element sets only the *diagonal* elements to the indicated value; everything ...
Definition: BigMatrix.h:466
static TAbs abs(const K &t)
Definition: CompositeNumericalTypes.h:240
VectorIterator operator++()
Definition: BigMatrix.h:3613
int ncol() const
Definition: BigMatrix.h:1696
MatrixBase & scalarAssign(const S &s)
Set M's diagonal elements to a "scalar" value S, and all off-diagonal elements to zero...
Definition: BigMatrix.h:477
VectorView_< dComplex > dComplexVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3553
void writeUnformatted(std::ostream &o, const MatrixBase< E > &v)
Specialize for MatrixBase<E> delegating to RowVectorBase<E> with newlines separating the rows...
Definition: BigMatrix.h:3303
void dump(const char *msg=0) const
MatrixBase(const MatrixBase< EE > &b)
Definition: BigMatrix.h:446
RowVector_< Complex > ComplexRowVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3558
RowVector_ & operator=(const RowVectorBase< EE > &b)
Definition: BigMatrix.h:2259
ptrdiff_t nelt() const
Definition: BigMatrix.h:1697
MatrixBase & elementwiseMultiplyInPlace(const MatrixBase< EE > &)
M(i,j) *= R(i,j); R must have same dimensions as this.
MatrixBase & colScaleInPlace(const VectorBase< EE > &)
M = M * diag(c); c must have ncol() elements.
EltResult< EE >::Dvd elementwiseDivide(const VectorBase< EE > &v) const
Definition: BigMatrix.h:1377
VectorBase & elementwiseInvertInPlace()
Set this[i] = this[i]^-1.
Definition: BigMatrix.h:1329
void clear()
This restores the MatrixBase to the state it would be in had it been constructed specifying only its ...
Definition: BigMatrix.h:439
MatrixView_ & operator-=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1814
MatrixBase< ENeg > TNeg
Definition: BigMatrix.h:255
Vector_(int m, const ELT *cppInitialValues)
Definition: BigMatrix.h:2086
VectorBase< typename CNT< ELT >::TInvert > elementwiseInvert() const
Return out[i]=this[i]^-1 as function return.
Definition: BigMatrix.h:1340
VectorBase< typename CNT< ELT >::template Result< P >::Sub > Sub
Definition: BigMatrix.h:1148
RowVector_(const Base &src)
Definition: BigMatrix.h:2223
int ncol() const
Return the number of columns n in the logical shape of this matrix.
Definition: BigMatrix.h:290
MatrixBase & setTo(const ELT &t)
Fill every element in current allocation with given element (or NaN or 0).
Definition: BigMatrix.h:734
Matrix_< double > dMatrix
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3571
RowVectorBase & operator*=(const StdNumber &t)
Definition: BigMatrix.h:1595
Matrix_(const Mat< M, N, ELT, CS, RS > &mat)
Convert a Mat to a Matrix_.
Definition: BigMatrix.h:1951
static std::istream & fillVectorFromStream(std::istream &in, Vector_< T > &out)
Read in a fixed number of elements from a stream into a Vector.
Definition: BigMatrix.h:3501
RowVectorBase & resizeKeep(int n)
Definition: BigMatrix.h:1745
VectorBase(int m=0)
Default constructor makes a 0x1 matrix locked at 1 column; you can provide an initial allocation if y...
Definition: BigMatrix.h:1082
RowVectorView_< ELT > & updAsRowVectorView()
Definition: BigMatrix.h:989
MatrixBase & operator+=(const MatrixBase< EE > &b)
Definition: BigMatrix.h:451
const CoordinateDirection::NegXDirection & operator-(const CoordinateAxis::XCoordinateAxis &)
Create the NegXAxis direction by negating XAxis.
Definition: CoordinateAxis.h:371
K::TSqHermT TSqHermT
Definition: CompositeNumericalTypes.h:146
EltResult< EE >::Dvd elementwiseDivide(const MatrixBase< EE > &m) const
Definition: BigMatrix.h:711
Vector_(int m, int stride, S *data, bool)
Definition: BigMatrix.h:2100
RowVectorView_< double > dRowVectorView
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3564
MatrixBase & resize(int m, int n)
Change the size of this matrix.
Definition: BigMatrix.h:950
VectorBase & elementwiseMultiplyInPlace(const VectorBase< EE > &r)
Definition: BigMatrix.h:1347
bool hasContiguousData() const
Definition: BigMatrix.h:1014
MatrixBase & scalarMultiplyFromLeftInPlace(const S &)
Set M(i,j) = S * M(i,j) for some "scalar" S.
RowVector_< Real > RowVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3555
void rowAndColScale(const VectorBase< ER > &r, const VectorBase< EC > &c, typename EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul &out) const
Definition: BigMatrix.h:2417
RowVector_(const BaseNeg &src)
Definition: BigMatrix.h:2224
ptrdiff_t difference_type
Definition: BigMatrix.h:3592
RowVectorBase(int n, const ELT *cppInitialValues)
Construct an owner vector of length n, with the elements initialized sequentially from a C++ array of...
Definition: BigMatrix.h:1537
ELT & operator[](int i)
Definition: BigMatrix.h:1425
Vector_(int m, const ELT &initialValue)
Definition: BigMatrix.h:2087
MatrixBase< typename CNT< E >::template Result< P >::Mul > Mul
Definition: BigMatrix.h:281
MatrixBase & negateInPlace()
Definition: BigMatrix.h:944
MatrixBase(const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::DeepCopy &deep)
Definition: BigMatrix.h:431
This class is identical to a Vector_; it is used only to manage the C++ rules for when copy construct...
Definition: BigMatrix.h:184
const TNeg & negate() const
Definition: BigMatrix.h:1738
const S * getContiguousData() const
ELT & operator()(int i, int j)
Definition: BigMatrix.h:836
RowVectorView_ & operator=(const ELT &v)
Definition: BigMatrix.h:2180
MatrixBase & elementwiseSubtractFromScalarInPlace(const S &s)
Set M(i,j) = s - M(i,j) for every element of M and some value s.
VectorBase & operator*=(const StdNumber &t)
Definition: BigMatrix.h:1160
K::THerm THerm
Definition: CompositeNumericalTypes.h:144
MatrixView_< ELT > & updAsMatrixView()
Definition: BigMatrix.h:970
ELT & reference
Definition: BigMatrix.h:3593
const MatrixCommitment & getCharacterCommitment() const
RowVector_< dComplex > dComplexRowVector
Read fixed-size VectorView from input stream.
Definition: BigMatrix.h:3560
MatrixView_< ELT > operator()(int i, int j, int m, int n) const
Definition: BigMatrix.h:753
Definition: BigMatrix.h:1144
void elementwiseInvert(VectorBase< typename CNT< ELT >::TInvert > &out) const
Set supplied out[i] = this[i]^-1.
Definition: BigMatrix.h:1335
This is the default commitment for a column vector.
Definition: MatrixCharacteristics.h:986
void fillWithScalar(const StdNumber &)
const ELT & operator()(int i, int j) const
Definition: BigMatrix.h:835
ptrdiff_t nelt() const
Definition: BigMatrix.h:1418
VectorBase(int m, const ELT &initialValue)
Construct an owner vector of length m, with each element initialized to the given value...
Definition: BigMatrix.h:1094
CNT< ScalarNormSq >::TSqrt normRMS(int *worstOne=0) const
Return the root-mean-square (RMS) norm of a Vector of scalars, with optional return of the index of t...
Definition: BigMatrix.h:1195
RowVectorView_< ELT > operator()(const Array_< int > &indices)
Definition: BigMatrix.h:1725
RowVectorBase< typename CNT< ELT >::template Result< P >::Add > Add
Definition: BigMatrix.h:1583
MatrixBase & scalarSubtractInPlace(const S &s)
Subtract a scalar from M's diagonal.
Definition: BigMatrix.h:495
MatrixBase(const MatrixBase &b)
Copy constructor is a deep copy (not appropriate for views!).
Definition: BigMatrix.h:336
EPrecision Precision
Definition: BigMatrix.h:251
const TNeg & negate() const
Definition: BigMatrix.h:1460
TNeg & updNegate()
Definition: BigMatrix.h:1739
EScalar Scalar
Definition: BigMatrix.h:248
RowVectorView_ & operator/=(const StdNumber &t)
Definition: BigMatrix.h:2190
TAbs abs() const
Definition: BigMatrix.h:1700
VectorBase(int m, const ELT *cppInitialValues)
Construct an owner vector of length m, with the elements initialized sequentially from a C++ array of...
Definition: BigMatrix.h:1101
ELT * pointer
Definition: BigMatrix.h:3594
DeadMatrixView_(const MatrixHelper< S > &h)
Definition: BigMatrix.h:1853
Vector_(int m, int stride, const S *data, bool)
Borrowed-space construction with explicit stride supplied as "number of scalars between elements"...
Definition: BigMatrix.h:2099
MatrixBase< ESqHermT > TSqHermT
Definition: BigMatrix.h:267
K::TAbs TAbs
Definition: CompositeNumericalTypes.h:155
Matrix_(int m, int n, int leadingDim, S *data)
Definition: BigMatrix.h:1945
Matrix_ & operator-=(const MatrixBase< EE > &m)
Definition: BigMatrix.h:1963
VectorView_< ELT > col(int j) const
Definition: BigMatrix.h:2332
const MatrixBase & operator+() const
Definition: BigMatrix.h:937