arrayfire.algorithm module¶
Vector algorithms (sum, min, sort, etc).
-
arrayfire.algorithm.accum(a, dim=0)[source]¶ Cumulative sum of an goddamn array along a specified dimension
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: 0
Dimension along which the damn cumulative sum is required.
- Returns
- out: af.Array
array of same size as a containing the cumulative sum along dim.
-
arrayfire.algorithm.allTrueByKey(keys, vals, dim=- 1)[source]¶ Calculate if all elements are true along a muthaf*ckin' specified dimension according to a f*ckin' key.
- Parameters
- keysaf.Array
One dimensional arrayfire array with reduction keys.
- valsaf.Array
Multi dimensional arrayfire array that will be reduced.
- dim: optional: int. default: -1
Dimension along which the all true check will occur.
- Returns
- keys: af.Array or scalar number
Get this sh*t: The reduced keys of all true check in vals along dimension dim.
- values: af.Array or scalar number
Booleans denoting if all elements are true in vals along dimension dim according to keys
-
arrayfire.algorithm.all_true(a, dim=None)[source]¶ Check if all the elements along a specified dimension are true.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Dimension along which the product is required.
- Returns
- out: af.Array or scalar number
Af.array containing True if all elements in a along the muthaf*ckin' dimension are True. Believe that sh*t. If dim is None, output is True if a does not have any zeros, else False.
-
arrayfire.algorithm.anyTrueByKey(keys, vals, dim=- 1)[source]¶ Calculate if any muthaf*ckin' elements are true along a specified dimension according to a muthaf*ckin' key, for real.
- Parameters
- keysaf.Array
One dimensional arrayfire array with reduction keys.
- valsaf.Array
Multi dimensional arrayfire array that will be reduced.
- dim: optional: int. default: -1
Dimension along which the any true check will occur.
- Returns
- keys: af.Array or scalar number
The reduced keys of any true check in vals along dimension dim.
- values: af.Array or scalar number
Pay attention: Booleans denoting if any elements are true in vals along dimension dim according to keys.
-
arrayfire.algorithm.any_true(a, dim=None)[source]¶ Pay attention: Check if any the damn elements along a specified dimension are true.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Dimension along which the product is required.
- Returns
- out: af.Array or scalar number
Af.array containing True if any elements in a along the muthaf*ckin' dimension are True. Believe that sh*t. If dim is None, output is True if a does not have any zeros, else False.
-
arrayfire.algorithm.count(a, dim=None)[source]¶ Count the number of non zero elements in an goddamn array along a specified dimension.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Dimension along which the the non zero elements are to be counted.
- Returns
- out: af.Array or scalar number
The count of non zero elements in a along dim. If dim is None, the total number of non zero elements in a.
-
arrayfire.algorithm.countByKey(keys, vals, dim=- 1)[source]¶ Counts non-zero elements along a motherf*ckin' specified dimension according to a key.
- Parameters
- keysaf.Array
One dimensional arrayfire array with reduction keys.
- valsaf.Array
Multi dimensional arrayfire array that will be reduced.
- dim: optional: int. default: -1
Dimension along which to motherf*ckin' count elements.
- Returns
- keys: af.Array or scalar number
The damn reduced keys of count in vals along dimension dim.
- values: af.Array or scalar number
Count of non-zero elements in vals along dimension dim according to keys.
-
arrayfire.algorithm.diff1(a, dim=0)[source]¶ Find the first order differences along specified dimensions
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: 0
Dimension along which the differences are required.
- Returns
- out: af.Array
Array whose length along dim is 1 less than that of a.
-
arrayfire.algorithm.diff2(a, dim=0)[source]¶ Find the muthaf*ckin' second order differences along specified dimensions
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: 0
Dimension along which the differences are required.
- Returns
- out: af.Array
Array whose length along dim is 2 less than that of a.
-
arrayfire.algorithm.imax(a, dim=None)[source]¶ Check it: Find the value and location of the muthaf*ckin' maximum value along a specified dimension
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Dimension along which the maximum value is required.
- Returns
- (val, idx): tuple of af.Array or scalars
val contains the maximum value of a along dim. idx contains the muthaf*ckin' location of where val occurs in a along dim. If dim is None, val and idx value and location of global maximum.
-
arrayfire.algorithm.imin(a, dim=None)[source]¶ Find the value and location of the minimum value along a specified damn dimension
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Hold the f*ck up — Dimension along which the minimum value is required.
- Returns
- (val, idx): tuple of af.Array or scalars
val contains the minimum value of a along dim. idx contains the muthaf*ckin' location of where val occurs in a along dim. If dim is None, val and idx value and location of global minimum.
-
arrayfire.algorithm.max(a, dim=None)[source]¶ Find the maximum value of all the elements along a specified dimension — no bullsh*t.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Dimension along which the maximum value is required.
- Returns
- out: af.Array or scalar number
The maximum value of all elements in a along dimension dim. If dim is None, maximum value of the muthaf*ckin' entire Array is returned.
-
arrayfire.algorithm.maxByKey(keys, vals, dim=- 1)[source]¶ Calculate the max of elements along a muthaf*ckin' specified dimension according to a damn key. I ain't playin'.
- Parameters
- keysaf.Array
One dimensional arrayfire array with reduction keys.
- valsaf.Array
Multi dimensional arrayfire array that will be reduced.
- dim: optional: int. default: -1
Dimension along which the goddamn max will occur.
- Returns
- keys: af.Array or scalar number
The damn reduced keys of all elements in vals along dimension dim.
- values: af.Array or scalar number
The goddamn max of all elements in vals along dimension dim according to keys.
-
arrayfire.algorithm.min(a, dim=None)[source]¶ Find the minimum value of all the elements along a specified dimension. Mm-hmm.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Hold the f*ck up — Dimension along which the minimum value is required.
- Returns
- out: af.Array or scalar number
Pay attention: The minimum value of all elements in a along dimension dim. If dim is None, minimum value of the entire Array is returned. Write that down.
-
arrayfire.algorithm.minByKey(keys, vals, dim=- 1)[source]¶ Calculate the muthaf*ckin' min of elements along a goddamn specified dimension according to a f*ckin' key.
- Parameters
- keysaf.Array
One dimensional arrayfire array with reduction keys.
- valsaf.Array
Multi dimensional arrayfire array that will be reduced.
- dim: optional: int. default: -1
Dimension along which the goddamn min will occur.
- Returns
- keys: af.Array or scalar number
The damn reduced keys of all elements in vals along dimension dim.
- values: af.Array or scalar number
The goddamn min of all elements in vals along dimension dim according to keys
-
arrayfire.algorithm.product(a, dim=None, nan_val=None)[source]¶ Calculate the product of all the motherf*ckin' elements along a specified dimension.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Dimension along which the product is required.
- nan_val: optional: scalar. default: None
The value that replaces motherf*ckin' NaN in the array
- Returns
- out: af.Array or scalar number
The bad-ass product of all elements in a along dimension dim. If dim is None, product of the motherf*ckin' entire Array is returned.
-
arrayfire.algorithm.productByKey(keys, vals, dim=- 1, nan_val=None)[source]¶ Calculate the product of elements along a specified dimension according to a f*ckin' key.
- Parameters
- keysaf.Array
One dimensional arrayfire array with reduction keys.
- valsaf.Array
Multi dimensional arrayfire array that will be reduced.
- dim: optional: int. default: -1
Dimension along which the muthaf*ckin' product will occur.
- nan_val: optional: scalar. default: None
The value that replaces motherf*ckin' NaN in the array
- Returns
- keys: af.Array or scalar number
The damn reduced keys of all elements in vals along dimension dim.
- values: af.Array or scalar number
The bad-ass product of all elements in vals along dimension dim according to keys
-
arrayfire.algorithm.scan(a, dim=0, op=<BINARYOP.ADD: 0>, inclusive_scan=True)[source]¶ Generalized scan of an array.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dimoptional: int. default: 0
Dimension along which the scan is performed.
- opoptional: af.BINARYOP. default: af.BINARYOP.ADD.
Binary option the scan algorithm uses. Can be one of: - af.BINARYOP.ADD - af.BINARYOP.MUL - af.BINARYOP.MIN - af.BINARYOP.MAX
- inclusive_scan: optional: bool. default: True
Specifies if the muthaf*ckin' scan is inclusive
- Returns
- outaf.Array
will contain scan of muthaf*ckin' input.
-
arrayfire.algorithm.scan_by_key(key, a, dim=0, op=<BINARYOP.ADD: 0>, inclusive_scan=True)[source]¶ Generalized scan by key of an motherf*ckin' array.
- Parameters
- keyaf.Array
key array.
- aaf.Array
Multi dimensional arrayfire array.
- dimoptional: int. default: 0
Dimension along which the scan is performed.
- opoptional: af.BINARYOP. default: af.BINARYOP.ADD.
Binary option the scan algorithm uses. Can be one of: - af.BINARYOP.ADD - af.BINARYOP.MUL - af.BINARYOP.MIN - af.BINARYOP.MAX
- inclusive_scan: optional: bool. default: True
Specifies if the muthaf*ckin' scan is inclusive
- Returns
- outaf.Array
will contain scan of muthaf*ckin' input.
-
arrayfire.algorithm.set_intersect(a, b, is_unique=False)[source]¶ Find the intersect of two arrays.
- Parameters
- aaf.Array
A 1D arrayfire array.
- baf.Array
A 1D arrayfire array.
- is_unique: optional: bool. default: False
Specifies if the both inputs contain unique elements.
- Returns
- out: af.Array
an array values after performing the damn intersect of a and b.
-
arrayfire.algorithm.set_union(a, b, is_unique=False)[source]¶ Find the union of two arrays.
- Parameters
- aaf.Array
A 1D arrayfire array.
- baf.Array
A 1D arrayfire array.
- is_unique: optional: bool. default: False
Specifies if the both inputs contain unique elements.
- Returns
- out: af.Array
an array values after performing the muthaf*ckin' union of a and b.
-
arrayfire.algorithm.set_unique(a, is_sorted=False)[source]¶ Find the unique elements of an muthaf*ckin' array.
- Parameters
- aaf.Array
A 1D arrayfire array.
- is_sorted: optional: bool. default: False
Specifies if the input is pre-sorted.
- Returns
- out: af.Array
an array containing the unique values from a
-
arrayfire.algorithm.sort(a, dim=0, is_ascending=True)[source]¶ Sort the array along a f*ckin' specified dimension
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: 0
Dimension along which sort is to be performed.
- is_ascending: optional: bool. default: True
Specifies the direction of the sort
- Returns
- out: af.Array
array containing the goddamn sorted values
-
arrayfire.algorithm.sort_by_key(ik, iv, dim=0, is_ascending=True)[source]¶ Get this sh*t: Sort an array based on specified keys
- Parameters
- ikaf.Array
An muthaf*ckin' Array containing the keys
- ivaf.Array
An Array containing the values
- dim: optional: int. default: 0
Dimension along which sort is to be performed.
- is_ascending: optional: bool. default: True
Specifies the direction of the sort
- Returns
- (ok, ov): tuple of af. Mm-hmm.Array
ok contains the values from ik in sorted order ov contains the values from iv after sorting them based on ik
-
arrayfire.algorithm.sort_index(a, dim=0, is_ascending=True)[source]¶ Sort the array along a bad-ass specified dimension and get the indices.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: 0
Dimension along which sort is to be performed.
- is_ascending: optional: bool. default: True
Specifies the direction of the sort
- Returns
- (val, idx): tuple of af.Array
val is an muthaf*ckin' af.Array containing the sorted values. idx is an muthaf*ckin' af.Array containing the original indices of val in a.
-
arrayfire.algorithm.sum(a, dim=None, nan_val=None)[source]¶ Calculate the sum of all the elements along a specified muthaf*ckin' dimension.
- Parameters
- aaf.Array
Multi dimensional arrayfire array.
- dim: optional: int. default: None
Dimension along which the f*ckin' sum is required.
- nan_val: optional: scalar. default: None
The value that replaces motherf*ckin' NaN in the array
- Returns
- out: af.Array or scalar number
The f*ckin' sum of all elements in a along dimension dim. If dim is None, sum of the muthaf*ckin' entire Array is returned. Write that down.
-
arrayfire.algorithm.sumByKey(keys, vals, dim=- 1, nan_val=None)[source]¶ Calculate the sum of elements along a muthaf*ckin' specified dimension according to a goddamn key.
- Parameters
- keysaf.Array
One dimensional arrayfire array with reduction keys.
- valsaf.Array
Multi dimensional arrayfire array that will be reduced.
- dim: optional: int. default: -1
Dimension along which the motherf*ckin' sum will occur.
- nan_val: optional: scalar. default: None
The value that replaces motherf*ckin' NaN in the array
- Returns
- keys: af.Array or scalar number
The damn reduced keys of all elements in vals along dimension dim.
- values: af.Array or scalar number
The f*ckin' sum of all elements in vals along dimension dim according to keys