# arrayfire
**Repository Path**: chenpengfei0104/arrayfire
## Basic Information
- **Project Name**: arrayfire
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: BSD-3-Clause
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-04-07
- **Last Updated**: 2024-06-07
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
ArrayFire is a general-purpose library that simplifies the process of developing
software that targets parallel and massively-parallel architectures including
CPUs, GPUs, and other hardware acceleration devices.
Several of ArrayFire's benefits include:
* [Easy to use](http://arrayfire.org/docs/gettingstarted.htm), stable,
[well-documented](http://arrayfire.org/docs) API
* Rigorously tested for performance and accuracy
* Commercially friendly open-source licensing
* Commercial support from [ArrayFire](http://arrayfire.com)
* [Read about more benefits on arrayfire.com](http://arrayfire.com/the-arrayfire-library/)
ArrayFire provides software developers with a high-level
abstraction of data which resides on the accelerator, the `af::array` object.
Developers write code which performs operations on ArrayFire arrays which, in turn,
are automatically translated into near-optimal kernels that execute on the computational
device.
ArrayFire is successfully used on devices ranging from low-power mobile phones
to high-power GPU-enabled supercomputers. ArrayFire runs on CPUs from all
major vendors (Intel, AMD, ARM), GPUs from the prominent manufacturers
(NVIDIA, AMD, and Qualcomm), as well as a variety of other accelerator devices
on Windows, Mac, and Linux.
## Installation
You can install the ArrayFire library from one of the following ways:
#### Official installers
Execute one of our [official binary installers](https://arrayfire.com/download)
for Linux, OSX, and Windows platforms.
#### Build from source
Build from source by following instructions on our
[wiki](https://github.com/arrayfire/arrayfire/wiki).
## Examples
The following examples are simplified versions of
[`helloworld.cpp`](https://github.com/arrayfire/arrayfire/blob/master/examples/helloworld/helloworld.cpp)
and
[`conway_pretty.cpp`](https://github.com/arrayfire/arrayfire/blob/master/examples/graphics/conway_pretty.cpp),
respectively. For more code examples, visit the
[`examples/`](https://github.com/arrayfire/arrayfire/blob/master/examples/)
directory.
#### Hello, world!
```cpp
array A = randu(5, 3, f32); // Create 5x3 matrix of random floats on the GPU
array B = sin(A) + 1.5; // Element-wise arithmetic
array C = fft(B); // Fourier transform the result
float d[] = { 1, 2, 3, 4, 5, 6 };
array D(2, 3, d, afHost); // Create 2x3 matrix from host data
D.col(0) = D.col(end); // Copy last column onto first
array vals, inds;
sort(vals, inds, A); // Sort A and print sorted array and corresponding indices
af_print(vals);
af_print(inds);
```
#### Conway's Game of Life
Visit the
[Wikipedia page](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) for a
description of Conway's Game of Life.
```cpp
static const float h_kernel[] = {1, 1, 1, 1, 0, 1, 1, 1, 1};
static const array kernel(3, 3, h_kernel, afHost);
array state = (randu(128, 128, f32) > 0.5).as(f32); // Generate starting state
Window myWindow(256, 256);
while(!myWindow.close()) {
array nHood = convolve(state, kernel); // Obtain neighbors
array C0 = (nHood == 2); // Generate conditions for life
array C1 = (nHood == 3);
state = state * C0 + C1; // Update state
myWindow.image(state); // Display
}
```