/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * PANIC * Portable Algorithms and Numerics In C++ * * Scientific computing from scratch, with feeling. * * Copyright (c) 2026 Michelle Bausager * * This file is part of PANIC. * * PANIC is free software licensed under the GNU General Public License v3.0 or later. * You may redistribute and/or modify it under the terms of the GPL. * * PANIC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the LICENSE file for the full license text. * * SPDX-License-Identifier: GPL-3.0-or-later * *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * Project Name: PANIC * Module Name: math * File Name: dot.hpp * Revision: 0.1.0 * Date: 31-07-2026 * Author: Michelle Bausager * * Description: * Functions to calculate dot product of tensors; * *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #pragma once //--------------------------------------------------------------------------------------------------------------------------- // INCLUDE DESCRIPTION //----------------------------------------------------------------------------------------------------- #include #include // for panic::real_matrix namespace panic{ namespace math{ /** * @brief Returns dor product of vector and vector. * * Computes: * @code * @endcode * * @tparam T Numeric element type. * @param a First vector. * @param b Second vector for dot product. Need to be @p a.size() * */ template T dot(const panic::tensor::vector& a, const panic::tensor::vector& b); /** * @brief Returns a new vector of dot product of a matrix and vector. * * Computes: * @code * @endcode * * @tparam T Numeric element type. * @param A Input matrix. * @param b Input vector. @ p b.size needs to be the size of @p A.cols. * @param c Output vector with result. * * @return true if success * @return false if resizeing fails or dimention mismatch * */ template bool dot(const panic::tensor::matrix& A, const panic::tensor::matrix& b, panic::tensor::vector& c); /** * @brief Returns a new vector of dot product of a matrix and vector. * * Computes: * @code * @endcode * * @tparam T Numeric element type. * @param A Input matrix. * @param b Input vector. @ p b.size needs to be the size of @p A.cols. * * @return A new matrix containing the result. * @return An empty vector if the operation fails. * * @note This overload is convenient, but may allocate a new matrix. */ template panic::tensor::vector dot(const panic::tensor::matrix& A, const panic::tensor::matrix& b); } // namespace math } // namespace panic