Buffer

  • namespace: Rindow\Math\Buffer\FFI
  • classname: Buffer

Buffer object for array. Allocate contiguous memory area.

Class implementation

namespace Rindow\OpenBLAS;
use ArrayAccess;
use Countable;
class Buffer implement ArrayAccess,Countable
{}

Methods

constructor

public function __construct(int $size,int $dtype);

Arguments

  • size: buffer size.
    • Number of elements in array. (Note that it is not the memory size)
  • dtype: data type.
    • Specify one of the data types defined in Interop\Polite\Math\Matrix\NDArray.

Example

use Interop\Polite\Math\Matrix\NDArray;
$buffer = new Rindow\OpenBLAS\Buffer(10,NDArray::float32);

offsetExists

public function offsetExists($offset)

One of the ArrayAccess interface.

Arguments

  • offset: Array access offset.
    • Must be an integer.

offsetGet

public function offsetGet($offset)

One of the ArrayAccess interface.

Arguments

  • offset: Array access offset.
    • Must be an integer.

offsetSet

public function offsetSet($offset,$value)

One of the ArrayAccess interface.

Arguments

  • offset: Array access offset.
    • Must be an integer.
  • value: Value to set.

offsetUnset

public function offsetUnset($offset)

One of the ArrayAccess interface.

Set the value of the element to 0. Element cannot be deleted.

Arguments

  • offset: Array access offset.
    • Must be an integer.

count

public function count()

One of the Countable interface.

Return

  • Number of elements in array.

dtype

public function dtype() : int

Array data type.

Return

  • Array data type.

dump

public function dump() : string

Returns the memory area of the array as a PHP string.

Return

  • binary string.

load

public function load(string $data) : void

Load PHP string type into memory area of array.

Arguments

  • data: binary string.