first model

This commit is contained in:
2026-07-29 17:34:22 +02:00
parent 47671354ce
commit f5e0ee209b
25 changed files with 2642 additions and 108 deletions
@@ -0,0 +1,96 @@
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* 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: neural_network
* File Name: sine_data.hpp
* Revision: 0.1.0
* Date: 29-07-2026
* Author: Michelle Bausager
*
* Description:
* Functions to generate dataset for neural networks;
*
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include <config/types.hpp>
#include <tensor/vector.hpp>
#include <tensor/matrix.hpp>
//---------------------------------------------------------------------------------------------------------------------------
// INPLEMENTATION
//---------------------------------------------------------------------------------------------------------------------------
namespace panic {
namespace neural_network {
/**
* @brief Generates a dataset of sines values
*
* Computes:
* @code
* csine(10, 1, X, y)
* @endcode
*
* @tparam T Numeric element type.
* @param samples Number of samples dataset.
* @param lenght Interval of the sinus cuve form zero.
* @param X Output X matrix
* @param y Output y matrix
*
* @return true if @p X and @p y was resized and filled successfully.
* @return false if resizing @p X or @p y failed.
*
* @note This funtion writes the result into an existing vector to avoid
* unnecessary temporary allocations.
*/
template <typename T>
bool sine_data(const panic::types::uint_t samples, const T lenght, panic::tensor::matrix<T>& X, panic::tensor::vector<T>& y);
/**
* @brief Generates a dataset of sines and cosine values
*
* Computes:
* @code
* csine(10, 1, X, y)
* @endcode
*
* @tparam T Numeric element type.
* @param samples Number of samples dataset.
* @param lenght Interval of the sinus cuve form zero.
* @param X Output X matrix
* @param y Output y matrix
*
* @return true if @p X and @p y was resized and filled successfully.
* @return false if resizing @p X or @p y failed.
*
* @note This funtion writes the result into an existing vector to avoid
* unnecessary temporary allocations.
*/
template <typename T>
bool sine_cosine_data(const panic::types::uint_t samples, const T lenght, panic::tensor::matrix<T>& X, panic::tensor::matrix<T>& y);
} // namespace neural_network
} // namespace panic
@@ -0,0 +1,74 @@
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* 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: neural_network
* File Name: spiral_data.hpp
* Revision: 0.1.0
* Date: 29-07-2026
* Author: Michelle Bausager
*
* Description:
* Functions to generate dataset for neural networks;
*
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include <config/types.hpp>
#include <tensor/vector.hpp>
#include <tensor/matrix.hpp>
//---------------------------------------------------------------------------------------------------------------------------
// INPLEMENTATION
//---------------------------------------------------------------------------------------------------------------------------
namespace panic {
namespace neural_network {
/**
* @brief Generates a dataset of spiral values
*
* Computes:
* @code
* spiral_data(10, 1, X, y)
* @endcode
*
* @tparam T Numeric element type.
* @param samples Number of samples dataset.
* @param classes Number of classes in the spiral data.
* @param X Output X matrix
* @param y Output y matrix
*
* @return true if @p X and @p y was resized and filled successfully.
* @return false if resizing @p X or @p y failed.
*
* @note This funtion writes the result into an existing vector to avoid
* unnecessary temporary allocations.
*/
template <typename T>
bool spiral_data(const panic::types::uint_t samples, const panic::types::uint_t classes, panic::tensor::matrix<T>& X, panic::tensor::uint_vector& y);
} // namespace neural_network
} // namespace panic
@@ -0,0 +1,74 @@
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* 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: neural_network
* File Name: vertical_data.hpp
* Revision: 0.1.0
* Date: 29-07-2026
* Author: Michelle Bausager
*
* Description:
* Functions to generate dataset for neural networks;
*
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include <config/types.hpp>
#include <tensor/vector.hpp>
#include <tensor/matrix.hpp>
//---------------------------------------------------------------------------------------------------------------------------
// INPLEMENTATION
//---------------------------------------------------------------------------------------------------------------------------
namespace panic {
namespace neural_network {
/**
* @brief Generates a dataset of vertical values
*
* Computes:
* @code
* vertical_data(10, 1, X, y)
* @endcode
*
* @tparam T Numeric element type.
* @param samples Number of samples dataset.
* @param classes Number of classes in the vertical data.
* @param X Output X matrix
* @param y Output y matrix
*
* @return true if @p X and @p y was resized and filled successfully.
* @return false if resizing @p X or @p y failed.
*
* @note This funtion writes the result into an existing vector to avoid
* unnecessary temporary allocations.
*/
template <typename T>
bool vertical_data(const panic::types::uint_t samples, const panic::types::uint_t classes, panic::tensor::matrix<T>& X, panic::tensor::uint_vector& y);
} // namespace neural_network
} // namespace panic