copy (Linear Algebra)


Import

#include <archr/algebra/copy.h>
#include <archr/algebra/copy.hpp>

Synopsis

 void archr_algebra_copy_f32(float *dst, const float *src, size_t nbelem);
(1)
 void archr_algebra_copy_f64(double *dst, const double *src, size_t nbelem);
(2)
 void archr_algebra_copy_zf32(void *dst, const void *src, size_t nbelem);
(3)
 void archr_algebra_copy_zf64(void *dst, const void *src, size_t nbelem);
(4)
 void archr_algebra_copyr_f32(float *dst, const float *first, const float *last);
(5)
 void archr_algebra_copyr_f64(double *dst, const double *first, const double *last);
(6)
 void archr_algebra_copyr_zf32(void *dst, const void *first, const void *last);
(7)
 void archr_algebra_copyr_zf64(void *dst, const void *first, const void *last);
(8)
 void copy(const float *src, size_t nbelem, float *dst);
(1)
 void copy(const double *src, size_t nbelem, double *dst);
(2)
 void copy(const std::complex<float>*src, size_t nbelem, std::complex<float>*dst);
(3)
 void copy(const std::complex<double>*src, size_t nbelem, std::complex<double>*dst);
(4)
 void copy(const float *first, const float *last, float *dst);
(5)
 void copy(const double *first, const double *last, double *dst);
(6)
 void copy(const std::complex<float>*first, const std::complex<float>*last, std::complex<float>*dst);
(7)
 void copy(const std::complex<double>*first, const std::complex<double>*last, std::complex<double>*dst);
(8)
template <typename Range> void copy(const Range& src, Range& dst);
(9)
subroutine archr_algebra_copy_f32(real(4), dimension(*), parameter :: src, integer(4) :: nbelem, real(4), dimension(*) :: dst)
(1)
subroutine archr_algebra_copy_f64(real(8), dimension(*), parameter :: src, integer(4) :: nbelem, real(8), dimension(*) :: dst)
(2)
subroutine archr_algebra_copy_zf32(complex(4), dimension(*), parameter :: src, integer(4) :: nbelem, complex(4), dimension(*) :: dst)
(3)
subroutine archr_algebra_copy_zf64(complex(8), dimension(*), parameter :: src, integer(4) :: nbelem, complex(8), dimension(*) :: dst)
(4)

Description

This function copy every elements of the source range into the destination stored in:

Parameters

src, first

the beginning of the source range.

last

the end of the source range.

dst

the beginning of the destination range.

nbelem

the number of elements to process.

Example

#include <archr/algebra/copy.h>
#include <stdio.h>

int main()
{
  int i, ok = 1;
  float v[4];
  float w[] = {2,4,6,8};

  printf("{");
  for(i=0;i<4;++i) printf("%f ",w[i]);
  puts("}");

  archr_algebra_copy_f32(&v[0], &w[0], 4);

  printf("{");
  for(i=0;i<4;++i) printf("%f ",v[i]);
  puts("}");

  return 0;
}

Possible Output

{2.000000 4.000000 6.000000 8.000000 }
{2.000000 4.000000 6.000000 8.000000 }
#include <archr/algebra/copy.hpp>
#include <iostream>
#include <vector>

int main()
{
  std::vector<float> v{1,3,5,7}, w{2,4,6,8};

  std::cout << "{";
  for(auto e : v) std::cout << e << " ";
  std::cout << "}\n";

  std::cout << "{";
  for(auto e : w) std::cout << e << " ";
  std::cout << "}\n\n";

  archr::algebra::copy(v,w);

  std::cout << "{";
  for(auto e : v) std::cout << e << " ";
  std::cout << "}\n";

  std::cout << "{";
  for(auto e : w) std::cout << e << " ";
  std::cout << "}\n";

  return 0;
}

Possible Output

{1 3 5 7 }
{2 4 6 8 }

{1 3 5 7 }
{1 3 5 7 }
program copy
  integer(4), parameter     :: sz = 9
  real(8)   , dimension(sz) :: dstf64, srcf64

  do i=1,sz
    srcf64(i) = i
  end do

  print *, srcf64

  call archr_algebra_copy_f64(dstf64, srcf64, size(dstf64))

  print *, dstf64

end program

Possible Output

   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000        6.0000000000000000        7.0000000000000000        8.0000000000000000        9.0000000000000000
   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000        6.0000000000000000        7.0000000000000000        8.0000000000000000        9.0000000000000000