.. _api_javascript_ndarrays: ======================== JavaScript API Reference ======================== ------- ------- NDArray ------- .. code:: javascript new dime.NDArray(order, shape, array, complex) Creates a new DiME NDArray object. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | order | {'C', 'F'} | The way the array is ordered. C-style (row-major) or Fortran-style | | | | (column-major). | +------------------+--------------------------------+-------------------------------------------------------------------------+ | shape | number, ... | The length of each dimension of the array. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | array | number[] | Optional. An already formatted array to be converted into an NDArray. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | complex | boolean | Optional. Defaults to *false*. Whether the NDArray will consist of | | | | complex numbers or not. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | NDArray | The newly created NDArray object. | +--------------------------------+--------------------------------------------------------------------+ --- get --- .. code:: javascript NDArray.get(index) Returns the value of the NDArray at the given index. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | index | number, ... | The index of a value in the array. In 2D NDArray, for example, it | | | | would be *(number, number)*. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | Value | The value of whatever has been stored in the NDArray at that | | | index. | +--------------------------------+--------------------------------------------------------------------+ --- set --- .. code:: javascript NDArray.set(value, index) Sets the given value at the index of the NDArray. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | value | number | The value you are storing. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | index | number, ... | The index that you intend to store ``value`` in. In a 2D NDArray, for | | | | example, it would be *(number, number)*. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ------ column ------ .. code:: javascript NDArray.column(n) Returns a given column from an NDArray. Only works for Fortran-style, 2D arrays. Does not support Complex matrices. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | n | number | The zero-indexed number of the column you would like returned. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | Value[] | The specified column. | +--------------------------------+--------------------------------------------------------------------+ --- row --- .. code:: javascript NDArray.row(n) Returns a given row from an NDArray. Only works for C-style, 2D arrays. Does not support Complex matrices. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | n | number | The zero-indexed number of the row you would like returned. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | Value[] | The specified row. | +--------------------------------+--------------------------------------------------------------------+ ------- extents ------- .. code:: javascript NDArray.extents() Returns the starting and ending point of an NDarray formated like a column vector. Does not support Complex matrices. NDArray must be contiguous. +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | {begin, end} | An object containing the extents of the NDArray. | +--------------------------------+--------------------------------------------------------------------+ -------- subarray -------- .. code:: javascript NDArray.subarray({being, end}) Returns the subarray of the NDArray based on the beginning and ending points provided. Does not support Complex matrices. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | {begin, end} | {number, number} | An object containing the specified beginning and end points. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | NDArray | A new NDArray made from the NDArray that called Subarray. | +--------------------------------+--------------------------------------------------------------------+ -------- subindex -------- .. code:: javascript NDArray.subindex(idx) Creates a new NDArray based on the stored values in ``idx``. Does not support Complex matrices. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | idx | NDArray | An NDArray where each value corresponds to an index in the NDArray that | | | | called Subindex. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | NDArray | A new NDArray made from the indeces contained in ``idx``. | +--------------------------------+--------------------------------------------------------------------+