OSVR-Core
ContentsInvalid.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_ContentsInvalid_h_GUID_E3C95D05_0BEF_4A9F_933A_35FD0B7D3745
26 #define INCLUDED_ContentsInvalid_h_GUID_E3C95D05_0BEF_4A9F_933A_35FD0B7D3745
27 
28 // Internal Includes
30 #include <osvr/Kalman/PoseState.h>
31 
32 // Library/third-party includes
33 // - none
34 
35 // Standard includes
36 // - none
37 
41 inline bool contentsInvalid(double n) { return !(n == 0. || std::isnormal(n)); }
42 
44 template <typename Derived>
46  return v.unaryExpr(
47  [](typename Derived::Scalar s) { return contentsInvalid(s); })
48  .any();
49 }
50 
53 template <typename Derived>
55  // If not zero and not normal, or if any of the diagonal values (variances)
56  // are negative.
57  return contentsInvalid(v) || (v.diagonal().array() < 0.).any();
58 }
59 
64  return contentsInvalid(state.stateVector()) ||
65  contentsInvalid(state.getQuaternion().coeffs());
66 }
67 
73 }
74 
75 inline bool
77  return stateContentsInvalid(state) || covarianceContentsInvalid(state);
78 }
79 
80 #endif // INCLUDED_ContentsInvalid_h_GUID_E3C95D05_0BEF_4A9F_933A_35FD0B7D3745
const Coefficients & coeffs() const
Definition: Quaternion.h:93
DiagonalReturnType diagonal()
Definition: Diagonal.h:168
bool stateContentsInvalid(osvr::kalman::pose_externalized_rotation::State const &state)
Applies contentsInvalid() to state aspects of a pose_externalized_rotation::State.
Definition: ContentsInvalid.h:62
const CwiseUnaryOp< CustomUnaryOp, const Derived > unaryExpr(const CustomUnaryOp &func=CustomUnaryOp()) const
Apply a unary operator coefficient-wise.
Definition: MatrixBase.h:140
bool covarianceContentsInvalid(Eigen::MatrixBase< Derived > const &v)
Applies contentsInvalid() to a covariance matrix, and also checks other invariant(s) of a covariance ...
Definition: ContentsInvalid.h:54
StateVector const & stateVector() const
xhat
Definition: PoseState.h:177
Header.
StateSquareMatrix const & errorCovariance() const
P.
Definition: PoseState.h:183
bool contentsInvalid(double n)
Are the contents of a value invalid? (Invalid is defined to be any "weird" floating point value - nan...
Definition: ContentsInvalid.h:41
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48