Files
panic/include/random/uniform.hpp
T
2026-07-29 17:34:22 +02:00

190 lines
5.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: random
* File Name: uniform.hpp
* Revision: 0.1.0
* Date: 29-06-2026
* Author: Michelle Bausager
*
* Description:
* Defindes the functions that returns values based on a uniform distribution.
*
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma once
//---------------------------------------------------------------------------------------------------------------------------
// INCLUDE DESCRIPTION
//---------------------------------------------------------------------------------------------------------------------------
#include <config/types.hpp> // panic::uint_t, panic::int_t, and panic::real_t
#include <tensor/vector.hpp>
#include <tensor/matrix.hpp>
//---------------------------------------------------------------------------------------------------------------------------
// DEFINE DESCRIPTION
//---------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------
// TYPE DESCRIPTION
//---------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------
// Function Name : panic::random::seed
//
// Description:
// base for random libary
//--------------------------------------------------------------------------------------------------------------------------
namespace panic{
namespace random{
/**
* @brief Returns a value from a uniform distribution bewteen 0 and 1.
*
* Computes:
* @code
* c = uniform();
* @endcode
*
* @return a value from a uniform distribution between 0 and 1
*
* @note This is not a omp-safe function
*/
panic::types::real_t uniform();
/**
* @brief Returns a value from a uniform distribution with limits.
*
* Computes:
* @code
* c = uniform(0.1f, 42.0f);
* @endcode
*
* @tparam T Numeric element type.
* @param min minimum limit for return value.
* @param max maximum limit for return value.
*
* @return a value from a uniform distribution with limits
*
* @note This is not a omp-safe function
*/
template <typename T>
T uniform(const T min, const T max);
/**
* @brief Filleds a vector with values from a uniform distribution from 0 to 1.
*
* Computes:
* @code
* panic::tensor::vector a(5);
* uniform(a);
* @endcode
*
* @tparam T Numeric element type.
* @param a Output vector filled iwht new values
*
* @return True of vector is filled correctly
*
* @note This is not a omp-safe function
*/
bool uniform(panic::tensor::real_vector& a);
/**
* @brief Filleds a vector with values from a uniform distribution from min to max.
*
* Computes:
* @code
* panic::tensor::real_vector a(5);
* uniform(a, 1.0f, 42.0f);
* @endcode
*
* @tparam T Numeric element type.
* @param a Output vector filled iwht new values
* @param min minimum limit for return value.
* @param max maximum limit for return value.
*
* @return True of vector is filled correctly
*
* @note This is not a omp-safe function
*/
template <typename T>
bool uniform(panic::tensor::vector<T>& a, const T min, const T max);
/**
* @brief Filleds a matrix with values from a uniform distribution from 0 to 1.
*
* Computes:
* @code
* panic::tensor::matrix A(5);
* uniform(A);
* @endcode
*
* @tparam T Numeric element type.
* @param a Output matrix filled with new values
*
* @return True of matrix is filled correctly
*
* @note This is not a omp-safe function
*/
bool uniform(panic::tensor::real_matrix& A);
/**
* @brief Filleds a matrix with values from a uniform distribution from min to max.
*
* Computes:
* @code
* panic::tensor::real_matrix A(5,5);
* uniform(A, 1.0f, 42.0f);
* @endcode
*
* @tparam T Numeric element type.
* @param a Output matrix filled with new values
* @param min minimum limit for return value.
* @param max maximum limit for return value.
*
* @return True of matrix is filled correctly
*
* @note This is not a omp-safe function
*/
template <typename T>
bool uniform(panic::tensor::matrix<T>& A, const T min, const T max);
/*
panic::tensor::real_vector uniform_vector(panic::tensor::real_vector& a);
panic::tensor::real_vector uniform_vector(const panic::types::real_t min, const panic::types::real_t max);
// Create and return vector
// Create and return matrix
*/
} // namespace random
} // namespace panic