acosd (Core Functions)


Import

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

Synopsis

 float archr_core_acosd_1f32(const float i1);
(1)
 double archr_core_acosd_1f64(const double i1);
(2)
 void archr_core_acosd_f32(float *o0, const float *i1, size_t sz);
(3)
 void archr_core_acosd_f64(double *o0, const double *i1, size_t sz);
(4)
 float acosd(const float i1);
(1)
 double acosd(const double i1);
(2)
 void acosd(const float *i1, size_t sz, float *o0);
(3)
 void acosd(const double *i1, size_t sz, double *o0);
(4)
template <typename Range> void acosd(const Range& i1, Range& o0);
(5)
subroutine archr_core_acosd_1f32(real(4) :: r, real(4), parameter :: i1)
(1)
subroutine archr_core_acosd_1f64(real(8) :: r, real(8), parameter :: i1)
(2)
subroutine archr_core_acosd_f32(real(4), dimension(*), parameter :: i1, integer(4) :: sz, real(4), dimension(*) :: o0)
(3)
subroutine archr_core_acosd_f64(real(8), dimension(*), parameter :: i1, integer(4) :: sz, real(8), dimension(*) :: o0)
(4)
def acosd(i1):
    return o0
(1)
function o0 = archr_core_acosd(i1)
(1)

Description

Computes the Inverse Cosine in Degree:

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/acosd.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)-1, (float)1);
  }
  archr_core_acosd_f32(o1, i1, sz);
  for (i = 0; i < sz; ++i) {
    printf("%4lu: acosd(%f) = %f\n", i, (double)i1[i], (double)o1[i]);
  }
}

Possible Output

   0: acosd(0.942286) = 19.560946
   1: acosd(0.183788) = 79.409515
   2: acosd(-0.326225) = 109.039825
   3: acosd(-0.782217) = 141.464035
   4: acosd(-0.500638) = 120.042213
   5: acosd(-0.805106) = 143.620514
   6: acosd(0.494578) = 60.358055
   7: acosd(0.934714) = 20.817972
   8: acosd(0.510651) = 59.292770
   9: acosd(0.634508) = 50.616508

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

Possible Output

   0: acosd(-0.782005) = 141.444
   1: acosd(-0.65429) = 130.866
   2: acosd(-0.937116) = 159.573
   3: acosd(0.569177) = 55.3071
   4: acosd(0.616947) = 51.9065
   5: acosd(0.746037) = 41.7518
   6: acosd(-0.236809) = 103.698
   7: acosd(-0.672507) = 132.261
   8: acosd(0.89037) = 27.0802
   9: acosd(-0.545268) = 123.043

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 = -1
    max0 = 1
  do i=1,sz
    r0 = random_in(min0, max0)
    i0(i) = r0
  end do
  ! Example:
  call archr_core_acosd_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 :    179.683487    
           2 :    137.470093    
           3 :    59.2555122    
           4 :    94.7437668    
           5 :    86.2424850    
           6 :    124.199905    
           7 :    154.946259    
           8 :    69.0392151    
           9 :    68.9862213    
          10 :    29.6126575