@@ -331,6 +331,55 @@ struct SquareMatrixOps< 2 >
331331 matrixA[ 1 ][ 1 ] * symMatrixB[ 1 ] * matrixA[ 0 ][ 1 ];
332332 }
333333
334+
335+ /* *
336+ * @brief Perform the outer product of @p vectorA with itself writing the result to @p dstMatrix.
337+ * @tparam M The size of both dimensions of @p dstMatrix and the length of @p vectorA.
338+ * @tparam DST_MATRIX The type of @p dstMatrix.
339+ * @tparam VECTOR_A The type of @p vectorA.
340+ * @param dstMatrix The matrix the result is written to, of size M x N.
341+ * @param vectorA The first vector in the outer product, of length M.
342+ * @details Performs the operations @code dstMatrix[ i ][ j ] = vectorA[ i ] * vectorA[ j ] @endcode
343+ */
344+ template < typename DST_MATRIX, typename VECTOR_A >
345+ LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK inline
346+ static void symRij_eq_AiAj ( DST_MATRIX && LVARRAY_RESTRICT_REF dstMatrix,
347+ VECTOR_A const & LVARRAY_RESTRICT_REF vectorA )
348+ {
349+ internal::checkSizes< 3 >( dstMatrix );
350+ internal::checkSizes< 2 >( vectorA );
351+
352+ dstMatrix[ 0 ] = vectorA[ 0 ] * vectorA[ 0 ];
353+ dstMatrix[ 1 ] = vectorA[ 1 ] * vectorA[ 1 ];
354+ dstMatrix[ 2 ] = vectorA[ 0 ] * vectorA[ 1 ];
355+ }
356+
357+ /* *
358+ * @brief Perform the unscaled symmetric outer product of @p vectorA and
359+ * @p vectorB writing the result to @p dstMatrix.
360+ * @tparam DST_MATRIX The type of @p dstMatrix.
361+ * @tparam VECTOR_A The type of @p vectorA.
362+ * @tparam VECTOR_B The type of @p vectorB.
363+ * @param dstMatrix The matrix the result is written to, of size M x N.
364+ * @param vectorA The first vector in the outer product, of length M.
365+ * @param vectorB The second vector in the outer product, of length M.
366+ * @details Performs the operations @code dstMatrix[ i ][ j ] = vectorA[ i ] * vectorB[ j ] + vectorA[ j ] * vectorB[ i ] @endcode
367+ */
368+ template < typename DST_SYM_MATRIX, typename VECTOR_A, typename VECTOR_B >
369+ LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK inline
370+ static void symRij_eq_AiBj_plus_AjBi ( DST_SYM_MATRIX && LVARRAY_RESTRICT_REF dstMatrix,
371+ VECTOR_A const & LVARRAY_RESTRICT_REF vectorA,
372+ VECTOR_B const & LVARRAY_RESTRICT_REF vectorB )
373+ {
374+ internal::checkSizes< 3 >( dstMatrix );
375+ internal::checkSizes< 2 >( vectorA );
376+ internal::checkSizes< 2 >( vectorB );
377+
378+ dstMatrix[ 0 ] = 2 * vectorA[ 0 ] * vectorB[ 0 ];
379+ dstMatrix[ 1 ] = 2 * vectorA[ 1 ] * vectorB[ 1 ];
380+ dstMatrix[ 2 ] = vectorA[ 0 ] * vectorB[ 1 ] + vectorA[ 1 ] * vectorB[ 0 ];
381+ }
382+
334383 /* *
335384 * @brief Compute the eigenvalues of the symmetric matrix @p symMatrix.
336385 * @tparam DST_VECTOR The type of @p eigenvalues.
@@ -890,6 +939,60 @@ struct SquareMatrixOps< 3 >
890939 matrixA[ 0 ][ 2 ] * symMatrixB[ 2 ] * matrixA[ 1 ][ 2 ];
891940 }
892941
942+ /* *
943+ * @brief Perform the outer product of @p vectorA with itself writing the result to @p dstMatrix.
944+ * @tparam M The size of both dimensions of @p dstMatrix and the length of @p vectorA.
945+ * @tparam DST_MATRIX The type of @p dstMatrix.
946+ * @tparam VECTOR_A The type of @p vectorA.
947+ * @param dstMatrix The matrix the result is written to, of size M x N.
948+ * @param vectorA The first vector in the outer product, of length M.
949+ * @details Performs the operations @code dstMatrix[ i ][ j ] = vectorA[ i ] * vectorA[ j ] @endcode
950+ */
951+ template < typename DST_MATRIX, typename VECTOR_A >
952+ LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK inline
953+ static void symRij_eq_AiAj ( DST_MATRIX && LVARRAY_RESTRICT_REF dstMatrix,
954+ VECTOR_A const & LVARRAY_RESTRICT_REF vectorA )
955+ {
956+ internal::checkSizes< 6 >( dstMatrix );
957+ internal::checkSizes< 3 >( vectorA );
958+
959+ dstMatrix[ 0 ] = vectorA[ 0 ] * vectorA[ 0 ];
960+ dstMatrix[ 1 ] = vectorA[ 1 ] * vectorA[ 1 ];
961+ dstMatrix[ 2 ] = vectorA[ 2 ] * vectorA[ 2 ];
962+ dstMatrix[ 3 ] = vectorA[ 1 ] * vectorA[ 2 ];
963+ dstMatrix[ 4 ] = vectorA[ 0 ] * vectorA[ 2 ];
964+ dstMatrix[ 5 ] = vectorA[ 0 ] * vectorA[ 1 ];
965+ }
966+
967+ /* *
968+ * @brief Perform the unscaled symmetric outer product of @p vectorA and
969+ * @p vectorB writing the result to @p dstMatrix.
970+ * @tparam DST_MATRIX The type of @p dstMatrix.
971+ * @tparam VECTOR_A The type of @p vectorA.
972+ * @tparam VECTOR_B The type of @p vectorB.
973+ * @param dstMatrix The matrix the result is written to, of size M x N.
974+ * @param vectorA The first vector in the outer product, of length M.
975+ * @param vectorB The second vector in the outer product, of length M.
976+ * @details Performs the operations @code dstMatrix[ i ][ j ] = vectorA[ i ] * vectorB[ j ] + vectorA[ j ] * vectorB[ i ] @endcode
977+ */
978+ template < typename DST_SYM_MATRIX, typename VECTOR_A, typename VECTOR_B >
979+ LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK inline
980+ static void symRij_eq_AiBj_plus_AjBi ( DST_SYM_MATRIX && LVARRAY_RESTRICT_REF dstMatrix,
981+ VECTOR_A const & LVARRAY_RESTRICT_REF vectorA,
982+ VECTOR_B const & LVARRAY_RESTRICT_REF vectorB )
983+ {
984+ internal::checkSizes< 6 >( dstMatrix );
985+ internal::checkSizes< 3 >( vectorA );
986+ internal::checkSizes< 3 >( vectorB );
987+
988+ dstMatrix[ 0 ] = 2 * vectorA[ 0 ] * vectorB[ 0 ];
989+ dstMatrix[ 1 ] = 2 * vectorA[ 1 ] * vectorB[ 1 ];
990+ dstMatrix[ 2 ] = 2 * vectorA[ 2 ] * vectorB[ 2 ];
991+ dstMatrix[ 3 ] = vectorA[ 1 ] * vectorB[ 2 ] + vectorA[ 2 ] * vectorB[ 1 ];
992+ dstMatrix[ 4 ] = vectorA[ 0 ] * vectorB[ 2 ] + vectorA[ 2 ] * vectorB[ 0 ];
993+ dstMatrix[ 5 ] = vectorA[ 0 ] * vectorB[ 1 ] + vectorA[ 1 ] * vectorB[ 0 ];
994+ }
995+
893996 /* *
894997 * @brief Compute the eigenvalues of the symmetric matrix @p symMatrix.
895998 * @tparam DST_VECTOR The type of @p eigenvalues.
0 commit comments