simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

resize.md (1134B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function resize
      4 
      5 Resize a matrix
      6 
      7 
      8 ## Syntax
      9 
     10 ```js
     11 math.resize(x, size)
     12 math.resize(x, size, defaultValue)
     13 ```
     14 
     15 ### Parameters
     16 
     17 Parameter | Type | Description
     18 --------- | ---- | -----------
     19 `x` | Array &#124; Matrix &#124; * | Matrix to be resized
     20 `size` | Array &#124; Matrix | One dimensional array with numbers
     21 `defaultValue` | number &#124; string | Zero by default, except in case of a string, in that case defaultValue = ' ' Default value: 0.
     22 
     23 ### Returns
     24 
     25 Type | Description
     26 ---- | -----------
     27 * &#124; Array &#124; Matrix | A resized clone of matrix `x`
     28 
     29 
     30 ### Throws
     31 
     32 Type | Description
     33 ---- | -----------
     34 
     35 
     36 ## Examples
     37 
     38 ```js
     39 math.resize([1, 2, 3, 4, 5], [3]) // returns Array  [1, 2, 3]
     40 math.resize([1, 2, 3], [5], 0)    // returns Array  [1, 2, 3, 0, 0]
     41 math.resize(2, [2, 3], 0)         // returns Matrix [[2, 0, 0], [0, 0, 0]]
     42 math.resize("hello", [8], "!")    // returns string 'hello!!!'
     43 ```
     44 
     45 
     46 ## See also
     47 
     48 [size](size.md),
     49 [squeeze](squeeze.md),
     50 [subset](subset.md),
     51 [reshape](reshape.md)