tenpower (Core Functions)


Import

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

Synopsis

 float archr_core_tenpower_1i8(const int8_t i1);
(1)
 float archr_core_tenpower_1i16(const int16_t i1);
(2)
 float archr_core_tenpower_1i32(const int32_t i1);
(3)
 double archr_core_tenpower_1i64(const int64_t i1);
(4)
 float archr_core_tenpower_1u8(const uint8_t i1);
(5)
 float archr_core_tenpower_1u16(const uint16_t i1);
(6)
 float archr_core_tenpower_1u32(const uint32_t i1);
(7)
 double archr_core_tenpower_1u64(const uint64_t i1);
(8)
 void archr_core_tenpower_i32(float *o0, const int32_t *i1, size_t sz);
(9)
 void archr_core_tenpower_i64(double *o0, const int64_t *i1, size_t sz);
(10)
 void archr_core_tenpower_u32(float *o0, const uint32_t *i1, size_t sz);
(11)
 void archr_core_tenpower_u64(double *o0, const uint64_t *i1, size_t sz);
(12)
 float tenpower(const int8_t i1);
(1)
 float tenpower(const int16_t i1);
(2)
 float tenpower(const int32_t i1);
(3)
 double tenpower(const int64_t i1);
(4)
 float tenpower(const uint8_t i1);
(5)
 float tenpower(const uint16_t i1);
(6)
 float tenpower(const uint32_t i1);
(7)
 double tenpower(const uint64_t i1);
(8)
 void tenpower(const int32_t *i1, size_t sz, float *o0);
(9)
 void tenpower(const int64_t *i1, size_t sz, double *o0);
(10)
 void tenpower(const uint32_t *i1, size_t sz, float *o0);
(11)
 void tenpower(const uint64_t *i1, size_t sz, double *o0);
(12)
subroutine archr_core_tenpower_1i8(real(4) :: r, integer(1), parameter :: i1)
(1)
subroutine archr_core_tenpower_1i16(real(4) :: r, integer(2), parameter :: i1)
(2)
subroutine archr_core_tenpower_1i32(real(4) :: r, integer(4), parameter :: i1)
(3)
subroutine archr_core_tenpower_1i64(real(8) :: r, integer(8), parameter :: i1)
(4)
subroutine archr_core_tenpower_1u8(real(4) :: r, integer(1), parameter :: i1)
(5)
subroutine archr_core_tenpower_1u16(real(4) :: r, integer(2), parameter :: i1)
(6)
subroutine archr_core_tenpower_1u32(real(4) :: r, integer(4), parameter :: i1)
(7)
subroutine archr_core_tenpower_1u64(real(8) :: r, integer(8), parameter :: i1)
(8)
subroutine archr_core_tenpower_i32(integer(4), dimension(*), parameter :: i1, integer(4) :: sz, real(4), dimension(*) :: o0)
(9)
subroutine archr_core_tenpower_u32(integer(4), dimension(*), parameter :: i1, integer(4) :: sz, real(4), dimension(*) :: o0)
(10)
def tenpower(i1):
    return o0
(1)
function o0 = archr_core_tenpower(i1)
(1)

Description

Computes the tenpower:

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/tenpower.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));
  float* o1 = (float*)malloc(sz * sizeof(float));

  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_tenpower_i32(o1, i1, sz);
  for (i = 0; i < sz; ++i) {
    printf("%4lu: tenpower(%d) = %f\n", i, i1[i], (double)o1[i]);
  }
}

Possible Output

   0: tenpower(-7) = 0.000000
   1: tenpower(-6) = 0.000001
   2: tenpower(-9) = 0.000000
   3: tenpower(5) = 100000.000000
   4: tenpower(6) = 1000000.000000
   5: tenpower(7) = 10000000.000000
   6: tenpower(-2) = 0.010000
   7: tenpower(-6) = 0.000001
   8: tenpower(8) = 100000000.000000
   9: tenpower(-5) = 0.000010

#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <archr/core/tenpower.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<float> 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::tenpower(i1.data(), sz, o1.data());
  for (i = 0; i < sz; ++i) {
    std::cout << std::setw(4) << i << ": " << "tenpower" << "(" << i1[i] << ")" << " = " << o1[i] << std::endl;
  }
}

Possible Output

   0: tenpower(-3) = 0.001
   1: tenpower(0) = 1
   2: tenpower(2) = 100
   3: tenpower(8) = 1e+08
   4: tenpower(-6) = 1e-06
   5: tenpower(-3) = 0.001
   6: tenpower(-7) = 1e-07
   7: tenpower(-4) = 0.0001
   8: tenpower(-8) = 1e-08
   9: tenpower(-2) = 0.01

program main
  integer(4), parameter  :: sz = 10
  real(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_tenpower_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.99999972E-10
           2 :    1.00000001E-07
           3 :    100000.000    
           4 :    1.00000000    
           5 :    1.00000000    
           6 :    9.99999975E-06
           7 :    9.99999972E-10
           8 :    1000.00000    
           9 :    1000.00000    
          10 :    100000000.