ifloor (Core Functions)


Import

#include <archr/core/ifloor.h>
#include <archr/core/ifloor.hpp>
import archr.core
atomsLoads('archr')

Synopsis

 int32_t archr_core_ifloor_1f32(const float i1);
(1)
 int64_t archr_core_ifloor_1f64(const double i1);
(2)
 int8_t archr_core_ifloor_1i8(const int8_t i1);
(3)
 int16_t archr_core_ifloor_1i16(const int16_t i1);
(4)
 int32_t archr_core_ifloor_1i32(const int32_t i1);
(5)
 int64_t archr_core_ifloor_1i64(const int64_t i1);
(6)
 uint8_t archr_core_ifloor_1u8(const uint8_t i1);
(7)
 uint16_t archr_core_ifloor_1u16(const uint16_t i1);
(8)
 uint32_t archr_core_ifloor_1u32(const uint32_t i1);
(9)
 uint64_t archr_core_ifloor_1u64(const uint64_t i1);
(10)
 void archr_core_ifloor_f32(int32_t *o0, const float *i1, size_t sz);
(11)
 void archr_core_ifloor_f64(int64_t *o0, const double *i1, size_t sz);
(12)
 void archr_core_ifloor_i8(int8_t *o0, const int8_t *i1, size_t sz);
(13)
 void archr_core_ifloor_i16(int16_t *o0, const int16_t *i1, size_t sz);
(14)
 void archr_core_ifloor_i32(int32_t *o0, const int32_t *i1, size_t sz);
(15)
 void archr_core_ifloor_i64(int64_t *o0, const int64_t *i1, size_t sz);
(16)
 void archr_core_ifloor_u8(uint8_t *o0, const uint8_t *i1, size_t sz);
(17)
 void archr_core_ifloor_u16(uint16_t *o0, const uint16_t *i1, size_t sz);
(18)
 void archr_core_ifloor_u32(uint32_t *o0, const uint32_t *i1, size_t sz);
(19)
 void archr_core_ifloor_u64(uint64_t *o0, const uint64_t *i1, size_t sz);
(20)
 int32_t ifloor(const float i1);
(1)
 int64_t ifloor(const double i1);
(2)
 int8_t ifloor(const int8_t i1);
(3)
 int16_t ifloor(const int16_t i1);
(4)
 int32_t ifloor(const int32_t i1);
(5)
 int64_t ifloor(const int64_t i1);
(6)
 uint8_t ifloor(const uint8_t i1);
(7)
 uint16_t ifloor(const uint16_t i1);
(8)
 uint32_t ifloor(const uint32_t i1);
(9)
 uint64_t ifloor(const uint64_t i1);
(10)
 void ifloor(const float *i1, size_t sz, int32_t *o0);
(11)
 void ifloor(const double *i1, size_t sz, int64_t *o0);
(12)
 void ifloor(const int8_t *i1, size_t sz, int8_t *o0);
(13)
 void ifloor(const int16_t *i1, size_t sz, int16_t *o0);
(14)
 void ifloor(const int32_t *i1, size_t sz, int32_t *o0);
(15)
 void ifloor(const int64_t *i1, size_t sz, int64_t *o0);
(16)
 void ifloor(const uint8_t *i1, size_t sz, uint8_t *o0);
(17)
 void ifloor(const uint16_t *i1, size_t sz, uint16_t *o0);
(18)
 void ifloor(const uint32_t *i1, size_t sz, uint32_t *o0);
(19)
 void ifloor(const uint64_t *i1, size_t sz, uint64_t *o0);
(20)
template <typename Range> void ifloor(const Range& i1, Range& o0);
(21)
subroutine archr_core_ifloor_1f32(integer(4) :: r, real(4), parameter :: i1)
(1)
subroutine archr_core_ifloor_1f64(integer(8) :: r, real(8), parameter :: i1)
(2)
subroutine archr_core_ifloor_1i8(integer(1) :: r, integer(1), parameter :: i1)
(3)
subroutine archr_core_ifloor_1i16(integer(2) :: r, integer(2), parameter :: i1)
(4)
subroutine archr_core_ifloor_1i32(integer(4) :: r, integer(4), parameter :: i1)
(5)
subroutine archr_core_ifloor_1i64(integer(8) :: r, integer(8), parameter :: i1)
(6)
subroutine archr_core_ifloor_1u8(integer(1) :: r, integer(1), parameter :: i1)
(7)
subroutine archr_core_ifloor_1u16(integer(2) :: r, integer(2), parameter :: i1)
(8)
subroutine archr_core_ifloor_1u32(integer(4) :: r, integer(4), parameter :: i1)
(9)
subroutine archr_core_ifloor_1u64(integer(8) :: r, integer(8), parameter :: i1)
(10)
subroutine archr_core_ifloor_f32(real(4), dimension(*), parameter :: i1, integer(4) :: sz, integer(4), dimension(*) :: o0)
(11)
subroutine archr_core_ifloor_f64(real(8), dimension(*), parameter :: i1, integer(4) :: sz, integer(8), dimension(*) :: o0)
(12)
subroutine archr_core_ifloor_i8(integer(1), dimension(*), parameter :: i1, integer(4) :: sz, integer(1), dimension(*) :: o0)
(13)
subroutine archr_core_ifloor_i16(integer(2), dimension(*), parameter :: i1, integer(4) :: sz, integer(2), dimension(*) :: o0)
(14)
subroutine archr_core_ifloor_i32(integer(4), dimension(*), parameter :: i1, integer(4) :: sz, integer(4), dimension(*) :: o0)
(15)
subroutine archr_core_ifloor_i64(integer(8), dimension(*), parameter :: i1, integer(4) :: sz, integer(8), dimension(*) :: o0)
(16)
subroutine archr_core_ifloor_u8(integer(1), dimension(*), parameter :: i1, integer(4) :: sz, integer(1), dimension(*) :: o0)
(17)
subroutine archr_core_ifloor_u16(integer(2), dimension(*), parameter :: i1, integer(4) :: sz, integer(2), dimension(*) :: o0)
(18)
subroutine archr_core_ifloor_u32(integer(4), dimension(*), parameter :: i1, integer(4) :: sz, integer(4), dimension(*) :: o0)
(19)
subroutine archr_core_ifloor_u64(integer(8), dimension(*), parameter :: i1, integer(4) :: sz, integer(8), dimension(*) :: o0)
(20)
def ifloor(i1):
    return o0
(1)
function o0 = archr_core_ifloor(i1)
(1)

Description

Computes the ifloor:

Parameters

i1_first, i1_last

The range of input elements

o0

The beginning of the destination range, may be equal to i1

i1

The scalar/contiguous data input element

Example


#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <archr/core/ifloor.h>

double rand_in(double min, double max) {
  return min + ((double)(max - min) * ((double)rand() / RAND_MAX));
}

int main() {
  time_t t;
  size_t i;
  size_t sz = 10;
  int32_t* i1 = (int32_t*)malloc(sz * sizeof(int32_t));
  int32_t* o1 = (int32_t*)malloc(sz * sizeof(int32_t));

  srand((unsigned int)time(&t));
  for (i = 0; i < sz; ++i) {
    i1[i] = (int32_t)rand_in((int32_t)-10, (int32_t)10);
  }
  archr_core_ifloor_i32(o1, i1, sz);
  for (i = 0; i < sz; ++i) {
    printf("%4lu: ifloor(%d) = %d\n", i, i1[i], o1[i]);
  }
}

Possible Output

   0: ifloor(-3) = -3
   1: ifloor(0) = 0
   2: ifloor(2) = 2
   3: ifloor(8) = 8
   4: ifloor(-6) = -6
   5: ifloor(-3) = -3
   6: ifloor(-7) = -7
   7: ifloor(-4) = -4
   8: ifloor(-8) = -8
   9: ifloor(-2) = -2

#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <archr/core/ifloor.hpp>

double rand_in(double min, double max) {
  return min + (double(max - min) * (double(std::rand()) / RAND_MAX));
}

int main() {
  std::size_t i;
  std::size_t sz = 10;
  std::vector<std::int32_t> i1(sz);
  std::vector<std::int32_t> o1(sz);

  std::srand(std::time(0));
  std::generate(i1.begin(), i1.end(), []() { return rand_in(std::int32_t(-10), std::int32_t(10)); });
  archr::core::ifloor(i1.data(), sz, o1.data());
  for (i = 0; i < sz; ++i) {
    std::cout << std::setw(4) << i << ": " << "ifloor" << "(" << i1[i] << ")" << " = " << o1[i] << std::endl;
  }
}

Possible Output

   0: ifloor(-3) = -3
   1: ifloor(0) = 0
   2: ifloor(2) = 2
   3: ifloor(8) = 8
   4: ifloor(-6) = -6
   5: ifloor(-3) = -3
   6: ifloor(-7) = -7
   7: ifloor(-4) = -4
   8: ifloor(-8) = -8
   9: ifloor(-2) = -2

program main
  integer(4), parameter  :: sz = 10
  integer(4), dimension(sz) :: o0
  integer(4), dimension(sz) :: i0
  real(8)                :: r0, r1
  real(8)                :: min0, max0
  real(8)                :: min1, max1
  real(8)                :: min2, max2
  ! Init:
    min0 = -10
    max0 = 10
  do i=1,sz
    r0 = random_in(min0, max0)
    i0(i) = int(r0)
  end do
  ! Example:
  call archr_core_ifloor_i32(o0, i0, size(i0))
  ! Output:
  do i=1,sz
    print *, i, ": ", o0(i)
  end do
contains
  ! Generate a random number within a range
  function random_in(mn, mx) result(r)
    real(8) :: r
    real(8), intent(in) :: mn, mx
    r = mn + (rand() * (mx - mn))
  end function random_in
end program

Possible Output

           1 :           -9
           2 :           -7
           3 :            5
           4 :            0
           5 :            0
           6 :           -5
           7 :           -9
           8 :            3
           9 :            3
          10 :            8