exp10 (Core Functions)


Import

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

Synopsis

 float archr_core_exp10_1f32(const float i1);
(1)
 double archr_core_exp10_1f64(const double i1);
(2)
 void archr_core_exp10_f32(float *o0, const float *i1, size_t sz);
(3)
 void archr_core_exp10_f64(double *o0, const double *i1, size_t sz);
(4)
 float exp10(const float i1);
(1)
 double exp10(const double i1);
(2)
 void exp10(const float *i1, size_t sz, float *o0);
(3)
 void exp10(const double *i1, size_t sz, double *o0);
(4)
template <typename Range> void exp10(const Range& i1, Range& o0);
(5)
subroutine archr_core_exp10_1f32(real(4) :: r, real(4), parameter :: i1)
(1)
subroutine archr_core_exp10_1f64(real(8) :: r, real(8), parameter :: i1)
(2)
subroutine archr_core_exp10_f32(real(4), dimension(*), parameter :: i1, integer(4) :: sz, real(4), dimension(*) :: o0)
(3)
subroutine archr_core_exp10_f64(real(8), dimension(*), parameter :: i1, integer(4) :: sz, real(8), dimension(*) :: o0)
(4)
def exp10(i1):
    return o0
(1)
function o0 = archr_core_exp10(i1)
(1)

Description

Computes the Base-Ten Exponential:

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

  srand((unsigned int)time(&t));
  for (i = 0; i < sz; ++i) {
    i1[i] = (float)rand_in((float)-10, (float)10);
  }
  archr_core_exp10_f32(o1, i1, sz);
  for (i = 0; i < sz; ++i) {
    printf("%4lu: exp10(%f) = %f\n", i, (double)i1[i], (double)o1[i]);
  }
}

Possible Output

   0: exp10(-3.466457) = 0.000342
   1: exp10(0.007624) = 1.017709
   2: exp10(2.723485) = 529.035706
   3: exp10(8.514454) = 326929344.000000
   4: exp10(-6.434300) = 0.000000
   5: exp10(-3.718313) = 0.000191
   6: exp10(-7.909604) = 0.000000
   7: exp10(-4.880131) = 0.000013
   8: exp10(-8.887694) = 0.000000
   9: exp10(-2.049582) = 0.008921

#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <archr/core/exp10.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<float> i1(sz);
  std::vector<float> o1(sz);

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

Possible Output

   0: exp10(-3.46646) = 0.00034162
   1: exp10(0.0076237) = 1.01771
   2: exp10(2.72348) = 529.036
   3: exp10(8.51445) = 3.26929e+08
   4: exp10(-6.4343) = 3.67875e-07
   5: exp10(-3.71831) = 0.000191288
   6: exp10(-7.9096) = 1.23139e-08
   7: exp10(-4.88013) = 1.31786e-05
   8: exp10(-8.88769) = 1.29511e-09
   9: exp10(-2.04958) = 0.0089211

program main
  integer(4), parameter  :: sz = 10
  real(4), dimension(sz) :: o0
  real(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) = r0
  end do
  ! Example:
  call archr_core_exp10_f32(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 :    1.00035140E-10
           2 :    4.27320295E-08
           3 :    129450.703    
           4 :   0.148936883    
           5 :    4.52211046    
           6 :    2.39431824E-06
           7 :    8.72750927E-10
           8 :    3778.24023    
           9 :    3854.11890    
          10 :    494148160.