#include <cstdio>
#include <cstdlib>
int main(int argc, char* argv[]) {
try {
int device = argc > 1 ? atoi(argv[1]) : 0;
printf("Create a 5-by-3 matrix of random floats on the GPU\n");
printf("Element-wise arithmetic\n");
printf("Negate the first three elements of second column\n");
B(
seq(0, 2), 1) = B(
seq(0, 2), 1) * -1;
printf("Fourier transform the result\n");
printf("Grab last row\n");
printf("Scan Test\n");
printf("Scan\n");
printf("Create 2-by-3 matrix from host data\n");
float d[] = {1, 2, 3, 4, 5, 6};
printf("Copy last column onto first\n");
printf("Sort A and print sorted array and corresponding indices\n");
fprintf(stderr,
"%s\n", e.
what());
throw;
}
return 0;
}
A multi dimensional data container.
Generic object that represents size and shape.
An ArrayFire exception class.
virtual const char * what() const
Returns an error message for the exception in a string format.
seq is used to create sequences for indexing af::array
@ f32
32-bit floating point values
array sin(const array &in)
C++ Interface to evaluate the sine function.
array::array_proxy col(int index)
Returns a reference to a col.
array::array_proxy row(int index)
Returns a reference to a row.
array constant(T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)
C++ Interface to generate an array with elements set to a specified value.
void setDevice(const int device)
Sets the current device.
array randu(const dim4 &dims, const dtype ty, randomEngine &r)
C++ Interface to create an array of random numbers uniformly distributed.
array scan(const array &in, const int dim=0, binaryOp op=AF_BINARY_ADD, bool inclusive_scan=true)
C++ Interface to scan an array (generalized) over a given dimension.
array fft(const array &in, const dim_t odim0=0)
C++ Interface for fast fourier transform on one dimensional signals.
array sort(const array &in, const unsigned dim=0, const bool isAscending=true)
C++ Interface to sort an array over a given dimension.
int end
A special value representing the last value of an axis.