Files

93 lines
2.3 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: tensor
* File Name: eye.hpp
* Revision: 0.1.0
* Date: 31-07-2026
* Author: Michelle Bausager
*
* Description:
* Functions to generate eye matrices
*
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma once
#include <tensor/matrix.hpp> // for panic::vector
#include <config/types.hpp>
namespace panic{
namespace tensor{
/**
* @brief Outputs an eye matrix
*
* Computes:
* @code
* @endcode
*
* @tparam T Numeric element type.
* @param size Number or rows and columns.
* @param A Output matrix
*
* @return true if @p A was resized and filled successfully.
* @return false if resizing @p A failed.
*
* @note This overload writes the result into an existing vector to avoid
* unnecessary temporary allocations.
*/
template <typename T>
bool eye(const panic::types::uint_t size, panic::tensor::matrix<T> A);
/**
* @brief Returns a eye matrix
*
* Computes:
* @code
* @endcode
*
* @param T Numeric element type.
* @param size Number of rows and columns.
*
* @return A new vector containing the result.
* @return An empty vector if the operation fails.
*
* @note This overload is convenient, but may allocate a new vector.
*/
//template <typename T>
//panic::tensor::matrix<T> eye(const T size);
} // namespace tensor
} // namespace panic