Files

86 lines
2.5 KiB
C++

/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* 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: transpose.hpp
* Revision: 0.1.0
* Date: 31-07-2026
* Author: Michelle Bausager
*
* Description:
* Functions to transpose a matrix;
*
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma once
//---------------------------------------------------------------------------------------------------------------------------
// INCLUDE DESCRIPTION
//-----------------------------------------------------------------------------------------------------
#include <tensor/matrix.hpp> // for panic::real_matrix
namespace panic{
namespace math{
/**
* @brief Transposes a matrix.
*
* Computes:
* @code
* B = transpose(A)
* @endcode
*
* @tparam T Numeric element type.
* @param A Input matrix.
* @param B Output matrix with result.
*
* @return true if success
* @return false if resizeing fails or dimention mismatch
*
*/
template <typename T>
bool transpose(const panic::tensor::matrix<T>& A, panic::tensor::matrix<T>& B);
/**
* @brief Returns a new matrix of the transposed A.
*
* Computes:
* @code
* result = transpose(A)
* @endcode
*
* @tparam T Numeric element type.
* @param A Input matrix.
*
* @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 <typename T>
panic::tensor::matrix<T> transpose(const panic::tensor::matrix<T>& A);
} // namespace math
} // namespace panic