| 109 | // and fails if there is a size mismatch. |
| 110 | template<typename Expression> |
| 111 | EIGEN_DEVICE_FUNC bool construct(Expression& expr) |
| 112 | { |
| 113 | // Check matrix sizes. If this is a compile-time vector, we do allow |
| 114 | // implicitly transposing. |
| 115 | EIGEN_STATIC_ASSERT( |
| 116 | EIGEN_PREDICATE_SAME_MATRIX_SIZE(PlainObjectType, Expression) |
| 117 | // If it is a vector, the transpose sizes might match. |
| 118 | || ( PlainObjectType::IsVectorAtCompileTime |
| 119 | && ((int(PlainObjectType::RowsAtCompileTime)==Eigen::Dynamic |
| 120 | || int(Expression::ColsAtCompileTime)==Eigen::Dynamic |
| 121 | || int(PlainObjectType::RowsAtCompileTime)==int(Expression::ColsAtCompileTime)) |
| 122 | && (int(PlainObjectType::ColsAtCompileTime)==Eigen::Dynamic |
| 123 | || int(Expression::RowsAtCompileTime)==Eigen::Dynamic |
| 124 | || int(PlainObjectType::ColsAtCompileTime)==int(Expression::RowsAtCompileTime)))), |
| 125 | YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES |
| 126 | ) |
| 127 | |
| 128 | // Determine runtime rows and columns. |
| 129 | Index rows = expr.rows(); |
| 130 | Index cols = expr.cols(); |
| 131 | if(PlainObjectType::RowsAtCompileTime==1) |
| 132 | { |
| 133 | eigen_assert(expr.rows()==1 || expr.cols()==1); |
| 134 | rows = 1; |
| 135 | cols = expr.size(); |
| 136 | } |
| 137 | else if(PlainObjectType::ColsAtCompileTime==1) |
| 138 | { |
| 139 | eigen_assert(expr.rows()==1 || expr.cols()==1); |
| 140 | rows = expr.size(); |
| 141 | cols = 1; |
| 142 | } |
| 143 | // Verify that the sizes are valid. |
| 144 | eigen_assert( |
| 145 | (PlainObjectType::RowsAtCompileTime == Dynamic) || (PlainObjectType::RowsAtCompileTime == rows)); |
| 146 | eigen_assert( |
| 147 | (PlainObjectType::ColsAtCompileTime == Dynamic) || (PlainObjectType::ColsAtCompileTime == cols)); |
| 148 | |
| 149 | |
| 150 | // If this is a vector, we might be transposing, which means that stride should swap. |
| 151 | const bool transpose = PlainObjectType::IsVectorAtCompileTime && (rows != expr.rows()); |
| 152 | // If the storage format differs, we also need to swap the stride. |
| 153 | const bool row_major = ((PlainObjectType::Flags)&RowMajorBit) != 0; |
| 154 | const bool expr_row_major = (Expression::Flags&RowMajorBit) != 0; |
| 155 | const bool storage_differs = (row_major != expr_row_major); |
| 156 | |
| 157 | const bool swap_stride = (transpose != storage_differs); |
| 158 | |
| 159 | // Determine expr's actual strides, resolving any defaults if zero. |
| 160 | const Index expr_inner_actual = resolveInnerStride(expr.innerStride()); |
| 161 | const Index expr_outer_actual = resolveOuterStride(expr_inner_actual, |
| 162 | expr.outerStride(), |
| 163 | expr.rows(), |
| 164 | expr.cols(), |
| 165 | Expression::IsVectorAtCompileTime != 0, |
| 166 | expr_row_major); |
| 167 | |
| 168 | // If this is a column-major row vector or row-major column vector, the inner-stride |
nothing calls this directly
no test coverage detected