{"id":1399,"url":"https://github.com/jjjkkkjjj/Matft","last_synced_at":"2025-08-02T04:31:01.745Z","repository":{"id":41369343,"uuid":"224340037","full_name":"jjjkkkjjj/Matft","owner":"jjjkkkjjj","description":"Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)","archived":false,"fork":false,"pushed_at":"2024-05-16T13:59:34.000Z","size":3366,"stargazers_count":140,"open_issues_count":8,"forks_count":22,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-11T07:36:15.517Z","etag":null,"topics":["complex-numbers","image","image-processing","math","matrix-library","ndarray","ndimensional-arrays","numpy","signal-processing","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jjjkkkjjj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-27T03:55:23.000Z","updated_at":"2025-06-20T01:18:02.000Z","dependencies_parsed_at":"2023-02-09T16:15:56.559Z","dependency_job_id":"76e9a87b-727f-4611-a9d3-1f7e020e978d","html_url":"https://github.com/jjjkkkjjj/Matft","commit_stats":{"total_commits":330,"total_committers":4,"mean_commits":82.5,"dds":"0.033333333333333326","last_synced_commit":"351a86c8ea9fb2995dfb93661e1f4efd054069de"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/jjjkkkjjj/Matft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjjkkkjjj%2FMatft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjjkkkjjj%2FMatft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjjkkkjjj%2FMatft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjjkkkjjj%2FMatft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jjjkkkjjj","download_url":"https://codeload.github.com/jjjkkkjjj/Matft/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjjkkkjjj%2FMatft/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334610,"owners_count":24233793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["complex-numbers","image","image-processing","math","matrix-library","ndarray","ndimensional-arrays","numpy","signal-processing","swift"],"created_at":"2024-01-05T20:15:45.551Z","updated_at":"2025-08-02T04:31:01.234Z","avatar_url":"https://github.com/jjjkkkjjj.png","language":"Swift","funding_links":[],"categories":["Math"],"sub_categories":["Other Hardware"],"readme":"# Matft\n\n![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-success) ![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-outdated-red)  ![Carthage compatible](https://img.shields.io/badge/Carthage-outdated-red) ![license](https://img.shields.io/badge/license-BSD--3-green)\n\n**Matft** is Numpy-like library in Swift. Function name and usage is similar to Numpy.\n\nINFO: Support Complex!!\n\n- [Matft](#matft)\n  * [Feature \u0026 Usage](#feature---usage)\n    + [Declaration](#declaration)\n      - [MfArray](#mfarray)\n      - [MfType](#mftype)\n    + [Subscription](#subscription)\n      - [MfSlice](#mfslice)\n      - [(Positive) Indexing](#-positive--indexing)\n      - [Slicing](#slicing)\n      - [Negative Indexing](#negative-indexing)\n      - [Boolean Indexing](#boolean-indexing)\n      - [Fancy Indexing](#boolean-indexing)\n      - [View](#view)\n    + [Complex](#complex)\n    + [Image](#image)\n  * [Function List](#function-list)\n  * [Performance](#performance)\n  * [Installation](#installation)\n    + [SwiftPM](#swiftpm)\n    + [Carthage](#carthage)\n    + [CocoaPods](#cocoapods)\n  * [Contact](#contact)\n\n\u003cstrike\u003e\nNote: You can use [Protocol version(beta version)](https://github.com/jjjkkkjjj/Matft/tree/protocol) too.\n\u003c/strike\u003e\n\n## Feature \u0026 Usage\n\n- Many types\n\n- Pretty print\n\n- Indexing\n\n  - Positive\n  - Negative\n  - **Boolean**\n  - **Fancy**\n  - **Complex**\n\n- Slicing\n\n  - Start / To / By\n  - New Axis\n\n- View\n\n  - Assignment\n\n- Conversion\n\n  - Broadcast\n  - Transpose\n  - Reshape\n  - Astype\n- **Univarsal function reduction**\n- Mathematic\n\n  - Arithmetic\n  - Statistic\n  - Linear Algebra\n- Complex\n- Image Conversion\n\n...etc.\n\nSee [Function List](#Function-List) for all functions.\n\n### Declaration\n\n#### MfArray\n\n- The **MfArray** such like a numpy.ndarray\n\n  ```swift\n  let a = MfArray([[[ -8,  -7,  -6,  -5],\n                    [ -4,  -3,  -2,  -1]],\n          \n                   [[ 0,  1,  2,  3],\n                    [ 4,  5,  6,  7]]])\n  let aa = Matft.arange(start: -8, to: 8, by: 1, shape: [2,2,4])\n  print(a)\n  print(aa)\n  /*\n  mfarray = \n  [[[\t-8,\t\t-7,\t\t-6,\t\t-5],\n  [\t-4,\t\t-3,\t\t-2,\t\t-1]],\n  \n  [[\t0,\t\t1,\t\t2,\t\t3],\n  [\t4,\t\t5,\t\t6,\t\t7]]], type=Int, shape=[2, 2, 4]\n  mfarray = \n  [[[\t-8,\t\t-7,\t\t-6,\t\t-5],\n  [\t-4,\t\t-3,\t\t-2,\t\t-1]],\n  \n  [[\t0,\t\t1,\t\t2,\t\t3],\n  [\t4,\t\t5,\t\t6,\t\t7]]], type=Int, shape=[2, 2, 4]\n  */\n  ```\n\n#### MfType\n\n- You can pass **MfType** as MfArray's argument ``mftype: .Hoge ``. It is similar to  `dtype`.\n  \n  ※Note that stored data type will be Float or Double only even if you set MfType.Int.\n  So, if you input big number to MfArray, it may be cause to overflow or strange results in any calculation (+, -, *, /,...  etc.). But I believe this is not problem in practical use.\n  \n- MfType's list is below\n  \n  ```swift\n\tpublic enum MfType: Int{\n      case None // Unsupportted\n      case Bool\n      case UInt8\n      case UInt16\n      case UInt32\n      case UInt64\n      case UInt\n      case Int8\n      case Int16\n      case Int32\n      case Int64\n      case Int\n      case Float\n      case Double\n      case Object // Unsupported\n  }\n  ```\n  \n- Also, you can convert MfType easily using ``astype``\n\n  ```swift\n  let a = MfArray([[[ -8,  -7,  -6,  -5],\n                    [ -4,  -3,  -2,  -1]],\n          \n                   [[ 0,  1,  2,  3],\n                    [ 4,  5,  6,  7]]])\n  print(a)//See above. if mftype is not passed, MfArray infer MfType. In this example, it's MfType.Int\n  \n  let a = MfArray([[[ -8,  -7,  -6,  -5],\n                    [ -4,  -3,  -2,  -1]],\n              \n                   [[ 0,  1,  2,  3],\n                    [ 4,  5,  6,  7]]], mftype: .Float)\n  print(a)\n  /*\n  mfarray = \n  [[[\t-8.0,\t\t-7.0,\t\t-6.0,\t\t-5.0],\n  [\t-4.0,\t\t-3.0,\t\t-2.0,\t\t-1.0]],\n  \n  [[\t0.0,\t\t1.0,\t\t2.0,\t\t3.0],\n  [\t4.0,\t\t5.0,\t\t6.0,\t\t7.0]]], type=Float, shape=[2, 2, 4]\n  */\n  let aa = MfArray([[[ -8,  -7,  -6,  -5],\n                    [ -4,  -3,  -2,  -1]],\n              \n                   [[ 0,  1,  2,  3],\n                    [ 4,  5,  6,  7]]], mftype: .UInt)\n  print(aa)\n  /*\n  mfarray = \n  [[[\t4294967288,\t\t4294967289,\t\t4294967290,\t\t4294967291],\n  [\t4294967292,\t\t4294967293,\t\t4294967294,\t\t4294967295]],\n  \n  [[\t0,\t\t1,\t\t2,\t\t3],\n  [\t4,\t\t5,\t\t6,\t\t7]]], type=UInt, shape=[2, 2, 4]\n  */\n  //Above output is same as numpy!\n  /*\n  \u003e\u003e\u003e np.arange(-8, 8, dtype=np.uint32).reshape(2,2,4)\n  array([[[4294967288, 4294967289, 4294967290, 4294967291],\n          [4294967292, 4294967293, 4294967294, 4294967295]],\n  \n         [[         0,          1,          2,          3],\n          [         4,          5,          6,          7]]], dtype=uint32)\n  */\n  \n  print(aa.astype(.Float))\n  /*\n  mfarray = \n  [[[\t-8.0,\t\t-7.0,\t\t-6.0,\t\t-5.0],\n  [\t-4.0,\t\t-3.0,\t\t-2.0,\t\t-1.0]],\n  \n  [[\t0.0,\t\t1.0,\t\t2.0,\t\t3.0],\n  [\t4.0,\t\t5.0,\t\t6.0,\t\t7.0]]], type=Float, shape=[2, 2, 4]\n  */\n  ```\n\n### Subscription\n\n#### MfSlice\n\n- You can access specific data using subscript.\n  \n\nYou can set **MfSlice** (see below's list) to subscript.\n\n  - ```swift\n    MfSlice(start: Int? = nil, to: Int? = nil, by: Int = 1)\n    ```\n  \n  - ```swift\n    Matft.newaxis\n    ```\n    \n  - ```swift\n    ~\u003c //this is prefix, postfix and infix operator. same as python's slice, \":\"\n    ```\n    \n  - ```swift\n    Matft.all // same as python's slice :, matft's 0~\u003c\n    ```\n\n  - ```swift\n    Matft.reverse // same as python's slice ::-1, matft's ~\u003c\u003c-1\n    ```\n\n#### (Positive) Indexing\n\n- Normal indexing\n  ```swift  \n  let a = Matft.arange(start: 0, to: 27, by: 1, shape: [3,3,3])\n  print(a)\n  /*\n  mfarray = \n  [[[\t0,\t\t1,\t\t2],\n  [\t3,\t\t4,\t\t5],\n  [\t6,\t\t7,\t\t8]],\n  \n  [[\t9,\t\t10,\t\t11],\n  [\t12,\t\t13,\t\t14],\n  [\t15,\t\t16,\t\t17]],\n  \n  [[\t18,\t\t19,\t\t20],\n  [\t21,\t\t22,\t\t23],\n  [\t24,\t\t25,\t\t26]]], type=Int, shape=[3, 3, 3]\n  */\n  print(a[2,1,0])\n  // 21\n  ```\n  \n  **Caution**\n  \n  MfArray conforms to Collection protocol, so 1D MfArray returns MfArray!\n  Use `item` as workaround instead of subscription such like\n  \n  ```swift\n  let a = Matft.arange(start: 0, to: 27, by: 1, shape: [27])\n  print(a[0])\n  /*\n  0 // a[0] is MfArray!! Nevertheless, The scalar is printed (I don't know why...)\n  */\n  print(a[0] + 4)\n  /*\n  mfarray = \n  [    4], type=Int, shape=[1]\n  */\n  \n  // Workaround\n  print(a.item(index: 0, type: Int.self))\n  /*\n  0\n  */\n  print(a.item(index: 0, type: Int.self) + 4)\n  /*\n  4\n  */\n  ```\n\n  #### Slicing\n\n- If you replace ``:`` with ``~\u003c``, you can get sliced mfarray.\n  Note that use `a[0~\u003c]` instead of `a[:]` to get all elements along axis.\n  \n  ```swift\n  print(a[~\u003c1])  //same as a[:1] for numpy\n  /*\n  mfarray = \n  [[[\t9,\t\t10,\t\t11],\n  [\t12,\t\t13,\t\t14],\n  [\t15,\t\t16,\t\t17]]], type=Int, shape=[1, 3, 3]\n  */\n  print(a[1~\u003c3]) //same as a[1:3] for numpy\n  /*\n  mfarray = \n  [[[\t9,\t\t10,\t\t11],\n  [\t12,\t\t13,\t\t14],\n  [\t15,\t\t16,\t\t17]],\n  \n  [[\t18,\t\t19,\t\t20],\n  [\t21,\t\t22,\t\t23],\n  [\t24,\t\t25,\t\t26]]], type=Int, shape=[2, 3, 3]\n  */\n  print(a[~\u003c~\u003c2]) //same as a[::2] for numpy\n  //print(a[~\u003c\u003c2]) //alias\n  /*\n  mfarray = \n  [[[\t0,\t\t1,\t\t2],\n  [\t3,\t\t4,\t\t5],\n  [\t6,\t\t7,\t\t8]],\n  \n  [[\t18,\t\t19,\t\t20],\n  [\t21,\t\t22,\t\t23],\n  [\t24,\t\t25,\t\t26]]], type=Int, shape=[2, 3, 3]\n  */\n  \n  print(a[Matft.all, 0]) //same as a[:, 0] for numpy\n  /*\n  mfarray = \n  [[    0,      1,      2],\n  [ 9,      10,     11],\n  [18,      19,     20]], type=Int, shape=[3, 3]\n  */\n  ```\n\n#### Negative Indexing\n\n- Negative indexing is also available\n  That's implementation was hardest for me...\n\n  ```swift\n  print(a[~\u003c-1])\n  /*\n  mfarray = \n  [[[\t0,\t\t1,\t\t2],\n  [\t3,\t\t4,\t\t5],\n  [\t6,\t\t7,\t\t8]],\n  \n  [[\t9,\t\t10,\t\t11],\n  [\t12,\t\t13,\t\t14],\n  [\t15,\t\t16,\t\t17]]], type=Int, shape=[2, 3, 3]\n  */\n  print(a[-1~\u003c-3])\n  /*\n  mfarray = \n  \t[], type=Int, shape=[0, 3, 3]\n  */\n  print(a[Matft.reverse])\n  //print(a[~\u003c~\u003c-1]) //alias\n  //print(a[~\u003c\u003c-1]) //alias\n  /*\n  mfarray = \n  [[[\t18,\t\t19,\t\t20],\n  [\t21,\t\t22,\t\t23],\n  [\t24,\t\t25,\t\t26]],\n  \n  [[\t9,\t\t10,\t\t11],\n  [\t12,\t\t13,\t\t14],\n  [\t15,\t\t16,\t\t17]],\n  \n  [[\t0,\t\t1,\t\t2],\n  [\t3,\t\t4,\t\t5],\n  [\t6,\t\t7,\t\t8]]], type=Int, shape=[3, 3, 3]*/\n  ```\n\n#### Boolean Indexing\n\n- You can use boolean indexing.\n\n  \u003cstrike\u003eCaution! I don't check performance, so this boolean indexing may be slow\u003c/strike\u003e\n\n  Unfortunately, Matft is too slower than numpy...\n  \n  (numpy is 1ms, Matft is 7ms...)\n  \n  ```swift\n  let img = MfArray([[1, 2, 3],\n                                 [4, 5, 6],\n                                 [7, 8, 9]], mftype: .UInt8)\n  img[img \u003e 3] = MfArray([10], mftype: .UInt8)\n  print(img)\n  /*\n  mfarray = \n  [[\t1,\t\t2,\t\t3],\n  [\t10,\t\t10,\t\t10],\n  [\t10,\t\t10,\t\t10]], type=UInt8, shape=[3, 3]\n  */\n  ```\n\n\n#### Fancy Indexing\n\n- You can use fancy indexing!!!\n\n  ```swift\n  let a = MfArray([[1, 2], [3, 4], [5, 6]])\n              \n  a[MfArray([0, 1, 2]), MfArray([0, -1, 0])] = MfArray([999,888,777])\n  print(a)\n  /*\n  mfarray = \n  [[\t999,\t\t2],\n  [\t3,\t\t888],\n  [\t777,\t\t6]], type=Int, shape=[3, 2]\n  */\n              \n  a.T[MfArray([0, 1, -1]), MfArray([0, 1, 0])] = MfArray([-999,-888,-777])\n  print(a)\n  /*\n  mfarray = \n  [[\t-999,\t\t-777],\n  [\t3,\t\t-888],\n  [\t777,\t\t6]], type=Int, shape=[3, 2]\n  */\n  ```\n\n#### View\n\n- Note that returned subscripted mfarray will have `base` property (is similar to `view` in Numpy). See [numpy doc](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.view.html) in detail.\n\n  ```swift\n  let a = Matft.arange(start: 0, to: 4*4*2, by: 1, shape: [4,4,2])\n              \n  let b = a[0~\u003c, 1]\n  b[~\u003c\u003c-1] = MfArray([9999]) // cannot pass Int directly such like 9999\n  \n  print(a)\n  /*\n  mfarray = \n  [[[\t0,\t\t1],\n  [\t9999,\t\t9999],\n  [\t4,\t\t5],\n  [\t6,\t\t7]],\n  \n  [[\t8,\t\t9],\n  [\t9999,\t\t9999],\n  [\t12,\t\t13],\n  [\t14,\t\t15]],\n  \n  [[\t16,\t\t17],\n  [\t9999,\t\t9999],\n  [\t20,\t\t21],\n  [\t22,\t\t23]],\n  \n  [[\t24,\t\t25],\n  [\t9999,\t\t9999],\n  [\t28,\t\t29],\n  [\t30,\t\t31]]], type=Int, shape=[4, 4, 2]\n  */\n  ```\n\n### Complex\n\nMatft supports Complex!!\n\nBut this is beta version. so, any bug may be ocurred.\n\nPlease report me by issue! ([Progres](https://github.com/jjjkkkjjj/Matft/issues/24)\n\n**TODO**\n\n- [x] Arithmetic Operation\n- [x] Angle, Conjugate and Absolute\n- [x] Math (partial: `sin,cos,tan,exp,log`)\n- [x] Basic Subscription Getter\n- [x] Basic Subscription Setter\n- [x] Boolean Indexing Getter\n- [ ] Boolean Indexing Setter\n- [x] Fancy Indexing Getter\n- [ ] Fancy Indexing Setter\n\n```swift\nlet real = Matft.arange(start: 0, to: 16, by: 1).reshape([2,2,4])\nlet imag = Matft.arange(start: 0, to: -16, by: -1).reshape([2,2,4])\nlet a = MfArray(real: real, imag: imag)\nprint(a)\n\n/*\nmfarray = \n[[[    0 +0j,        1 -1j,        2 -2j,        3 -3j],\n[    4 -4j,        5 -5j,        6 -6j,        7 -7j]],\n\n[[    8 -8j,        9 -9j,        10 -10j,        11 -11j],\n[    12 -12j,        13 -13j,        14 -14j,        15 -15j]]], type=Int, shape=[2, 2, 4]\n*/\n\nprint(a+a)\n/*\nmfarray = \n[[[    0 +0j,        2 -2j,        4 -4j,        6 -6j],\n[    8 -8j,        10 -10j,        12 -12j,        14 -14j]],\n\n[[    16 -16j,        18 -18j,        20 -20j,        22 -22j],\n[    24 -24j,        26 -26j,        28 -28j,        30 -30j]]], type=Int, shape=[2, 2, 4]\n*/\n\nprint(Matft.complex.angle(a))\n/*\nmfarray = \n[[[    -0.0,        -0.7853982,        -0.7853982,        -0.7853982],\n[    -0.7853982,        -0.7853982,        -0.7853982,        -0.7853982]],\n\n[[    -0.7853982,        -0.7853982,        -0.7853982,        -0.7853982],\n[    -0.7853982,        -0.7853982,        -0.7853982,        -0.7853982]]], type=Float, shape=[2, 2, 4]\n*/\n\nprint(Matft.complex.conjugate(a))\n/*\nmfarray = \n[[[    0 +0j,        1 +1j,        2 +2j,        3 +3j],\n[    4 +4j,        5 +5j,        6 +6j,        7 +7j]],\n\n[[    8 +8j,        9 +9j,        10 +10j,        11 +11j],\n[    12 +12j,        13 +13j,        14 +14j,        15 +15j]]], type=Int, shape=[2, 2, 4]\n*/\n```\n\n### Image\n\nYou can acheive an image processing by Matft! (Beta version)\nPlease refer to the example [here](./MatftDemo/MatftDemo/ViewController.swift).\n\n```swift\n@IBOutlet weak var originalImageView: UIImageView!\n@IBOutlet weak var reverseImageView: UIImageView!\n@IBOutlet weak var swapImageView: UIImageView!\n\nfunc reverse(){\n    var image = Matft.image.cgimage2mfarray(self.reverseImageView.image!.cgImage!)\n\n    // reverse\n    image = image[Matft.reverse] // same as image[~\u003c\u003c-1]\n    self.reverseImageView.image = UIImage(cgImage: Matft.image.mfarray2cgimage(image))\n}\n\n\nfunc swapchannel(){\n    var image = Matft.image.cgimage2mfarray(self.swapImageView.image!.cgImage!)\n\n    // swap channel\n    image = image[Matft.all, Matft.all, MfArray([1,0,2,3])] // same as image[0~\u003c, 0~\u003c, MfArray([1,0,2,3])]\n    self.swapImageView.image = UIImage(cgImage: Matft.image.mfarray2cgimage(image))\n}\n```\n\nFor more complex conversion, see OpenCV [code](https://github.com/opencv/opencv/blob/4.x/modules/imgcodecs/src/apple_conversions.mm).\n\n\u003cimg width=\"513\" alt=\"Screen Shot 2022-07-19 at 21 09 02\" src=\"https://user-images.githubusercontent.com/16914891/179746856-c4e8048d-3e7c-4835-b39c-ddf6af5b5fd7.png\"\u003e\n\n## Function List\n\nBelow is Matft's function list. As I mentioned above, almost functions are similar to Numpy. Also, these function use Accelerate framework inside, the perfomance may keep high.\n\n`*` means method function exists too. Shortly, you can use `a.shallowcopy()` where `a` is `MfArray`.\n\n`^` means method function only. Shortly, you can use `a.tolist()` **not** `Matft.tolist` where `a` is `MfArray`.\n\n`#` means support complex operation\n\n- Creation\n\n| Matft                      | Numpy             |\n| -------------------------- | ---------------- |\n| *#Matft.shallowcopy | *numpy.copy       |\n| *#Matft.deepcopy    | copy.deepcopy     |\n| Matft.nums         | numpy.ones * N    |\n| Matft.nums_like | numpy.ones_like * N |\n| Matft.arange       | numpy.arange      |\n| Matft.eye          | numpy.eye         |\n| Matft.diag         | numpy.diag        |\n| Matft.vstack       | numpy.vstack      |\n| Matft.hstack       | numpy.hstack      |\n| Matft.concatenate  | numpy.concatenate |\n| *Matft.append  | numpy.append |\n| *Matft.insert  | numpy.insert |\n| *Matft.take  | numpy.take |\n| ^MfArray.item  | ^numpy.ndarray.item |\n\n\n- Conversion\n\n| Matft                       | Numpy                    |\n| --------------------------- | ----------------------- |\n| *#Matft.astype       | *numpy.astype            |\n| *#Matft.transpose    | *numpy.transpose         |\n| *#Matft.expand_dims  | *numpy.expand_dims       |\n| *#Matft.squeeze      | *numpy.squeeze           |\n| *#Matft.broadcast_to | *numpy.broadcast_to      |\n| *#Matft.to_contiguous| *numpy.ascontiguousarray |\n| *#Matft.flatten      | *numpy.flatten           |\n| *#Matft.flip         | *numpy.flip              |\n| *#Matft.clip         | *numpy.clip              |\n| *#Matft.swapaxes     | *numpy.swapaxes          |\n| *#Matft.moveaxis     | *numpy.moveaxis          |\n| *Matft.roll          | numpy.roll          |\n| *Matft.sort         | *numpy.sort              |\n| *Matft.argsort      | *numpy.argsort           |\n| ^MfArray.toArray | ^numpy.ndarray.tolist |\n| ^MfArray.toFlattenArray | n/a |\n| ^MfArray.toMLMultiArray | n/a |\n| *Matft.orderedUnique | numpy.unique |\n\n- File\n\n| Matft                         | Numpy            |\n| ----------------------------- | :--------------- |\n| Matft.file.loadtxt    | numpy.loadtxt    |\n| Matft.file.genfromtxt | numpy.genfromtxt |\n| Matft.file.savetxt | numpy.savetxt |\n\n- Operation\n\n  Line 2 is infix (prefix) operator.\n\n| Matft                          | Numpy                      |\n| ------------------------------ | ------------------------- |\n| #Matft.add\u003cbr /\u003e+       | numpy.add\u003cbr /\u003e+           |\n| #Matft.sub\u003cbr /\u003e-       | numpy.sub\u003cbr /\u003e-           |\n| #Matft.div\u003cbr /\u003e/       | numpy.div\u003cbr /\u003e.           |\n| #Matft.mul\u003cbr /\u003e*       | numpy.multiply\u003cbr /\u003e*      |\n| Matft.inner\u003cbr /\u003e*+    | numpy.inner\u003cbr /\u003en/a       |\n| Matft.cross\u003cbr /\u003e*^    | numpy.cross\u003cbr /\u003en/a       |\n| Matft.matmul\u003cbr /\u003e*\u0026　　| numpy.matmul\u003cbr /\u003e@　      |\n| Matft.dot　　　         | numpy.dot   　             |\n| Matft.equal\u003cbr /\u003e===   | numpy.equal\u003cbr /\u003e==        |\n| Matft.not_equal\u003cbr /\u003e!==   | numpy.not_equal\u003cbr /\u003e!=        |\n| Matft.less\u003cbr /\u003e\u003c | numpy.less\u003cbr /\u003e\u003c |\n| Matft.less_equal\u003cbr /\u003e\u003c= | numpy.less_equal\u003cbr /\u003e\u003c= |\n| Matft.greater\u003cbr /\u003e\u003e | numpy.greater\u003cbr /\u003e\u003e |\n| Matft.greater_equal\u003cbr /\u003e\u003e= | numpy.greater_equal\u003cbr /\u003e\u003e= |\n| #Matft.allEqual\u003cbr /\u003e== | numpy.array_equal\u003cbr /\u003en/a |\n| #Matft.neg\u003cbr /\u003e-       | numpy.negative\u003cbr /\u003e-      |\n\n- Universal Fucntion Reduction\n\n| Matft                                                        | Numpy                                                   |\n| ------------------------------------------------------------ | ------------------------------------------------------- |\n| *#Matft.ufuncReduce\u003cbr /\u003ee.g.) Matft.ufuncReduce(a, Matft.add) | numpy.add.reduce\u003cbr /\u003ee.g.) numpy.add.reduce(a)         |\n| *#Matft.ufuncAccumulate\u003cbr /\u003ee.g.) Matft.ufuncAccumulate(a, Matft.add) | numpy.add.accumulate\u003cbr /\u003ee.g.) numpy.add.accumulate(a) |\n\n- Math function\n\n| Matft                    | Numpy       |\n| ------------------------ | ---------- |\n| #Matft.math.sin   | numpy.sin   |\n| Matft.math.asin  | numpy.asin  |\n| Matft.math.sinh  | numpy.sinh  |\n| Matft.math.asinh | numpy.asinh |\n| #Matft.math.cos   | numpy.cos   |\n| Matft.math.acos  | numpy.acos  |\n| Matft.math.cosh  | numpy.cosh  |\n| Matft.math.acosh | numpy.acosh |\n| #Matft.math.tan   | numpy.tan   |\n| Matft.math.atan  | numpy.atan  |\n| Matft.math.tanh  | numpy.tanh  |\n| Matft.math.atanh | numpy.atanh |\n| Matft.math.sqrt | numpy.sqrt |\n| Matft.math.rsqrt | numpy.rsqrt |\n| #Matft.math.exp | numpy.exp |\n| #Matft.math.log | numpy.log |\n| Matft.math.log2 | numpy.log2 |\n| Matft.math.log10 | numpy.log10 |\n| *Matft.math.ceil | numpy.ceil |\n| *Matft.math.floor | numpy.floor |\n| *Matft.math.trunc | numpy.trunc |\n| *Matft.math.nearest | numpy.nearest |\n| *Matft.math.round | numpy.round |\n| #Matft.math.abs | numpy.abs |\n| Matft.math.reciprocal | numpy.reciprocal |\n| #Matft.math.power | numpy.power |\n| Matft.math.arctan2 | numpy.arctan2 |\n| Matft.math.square | numpy.square |\n| Matft.math.sign | numpy.sign |\n\n- Statistics function\n\n| Matft                       | Numpy         |\n| --------------------------- | ------------ |\n| *Matft.stats.mean   | *numpy.mean   |\n| *Matft.stats.max    | *numpy.max    |\n| *Matft.stats.argmax | *numpy.argmax |\n| *Matft.stats.min    | *numpy.min    |\n| *Matft.stats.argmin | *numpy.argmin |\n| *Matft.stats.sum    | *numpy.sum    |\n| Matft.stats.maximum | numpy.maximum |\n| Matft.stats.minimum | numpy.minimum |\n| *Matft.stats.sumsqrt | n/a |\n| *Matft.stats.squaresum | n/a |\n| *Matft.stats.cumsum | *numpy.cumsum |\n\n- Random function\n\n| Matft                       | Numpy         |\n| --------------------------- | ------------ |\n| Matft.random.rand   | numpy.random.rand   |\n| Matft.random.randint    | numpy.random.randint    |\n\n- Linear algebra\n\n| Matft                            | Numpy              |\n| -------------------------------- | ----------------- |\n| Matft.linalg.solve       | numpy.linalg.solve |\n| Matft.linalg.inv         | numpy.linalg.inv   |\n| Matft.linalg.det         | numpy.linalg.det   |\n| Matft.linalg.eigen       | numpy.linalg.eig   |\n| Matft.linalg.svd         | numpy.linalg.svd   |\n| Matft.linalg.pinv | numpy.linalg.pinv |\n| Matft.linalg.polar_left  | scipy.linalg.polar |\n| Matft.linalg.polar_right | scipy.linalg.polar |\n| Matft.linalg.normlp_vec | scipy.linalg.norm |\n| Matft.linalg.normfro_mat | scipy.linalg.norm |\n| Matft.linalg.normnuc_mat | scipy.linalg.norm |\n\n- Complex\n\n| Matft                            | Numpy              |\n| -------------------------------- | ----------------- |\n| Matft.complex.angle       | numpy.angle |\n| Matft.complex.conjugate         | numpy.conj / numpy.conjugate   |\n| Matft.complex.abs         | numpy.abs / numpy.absolute   |\n\n- FFT\n\n| Matft                            | Numpy              |\n| -------------------------------- | ----------------- |\n| Matft.fft.rfft       | numpy.fft.rfft |\n| Matft.fft.irfft         | numpy.fft.irfft   |\n\n- Interpolation\n\nMatft supports only natural cubic spline. I'll implement other boundary condition later.\n\n| Matft                            | Scipy              |\n| -------------------------------- | ----------------- |\n| Matft.interp1d.cubicSpline       | scipy.interpolation.CubicSpline |\n\n- Image\n\n| Matft                            | Numpy              |\n| -------------------------------- | ----------------- |\n| Matft.image.cgimage2mfarray      | N/A |\n| Matft.image.mfarray2cgimage      | N/A |\n\n| Matft                            | OpenCV              |\n| -------------------------------- | ----------------- |\n| Matft.image.color               | cv2.cvtColor |\n| Matft.image.resize               | cv2.resize |\n| Matft.image.warpAffine               | cv2.warpAffine |\n\n\n## Performance\n\nI use `Accelerate` framework, so all of MfArray operation may keep high performance.\n\n```swift\nlet a = Matft.arange(start: 0, to: 10*10*10*10*10*10, by: 1, shape: [10,10,10,10,10,10])\nlet aneg = Matft.arange(start: 0, to: -10*10*10*10*10*10, by: -1, shape: [10,10,10,10,10,10])\nlet aT = a.T\nlet b = a.transpose(axes: [0,3,4,2,1,5])\nlet c = a.transpose(axes: [1,2,3,4,5,0])\nlet posb = a \u003e 0\n```\n\n```python\nimport numpy as np\n\na = np.arange(10**6).reshape((10,10,10,10,10,10))\naneg = np.arange(0, -10**6, -1).reshape((10,10,10,10,10,10))\naT = a.T\nb = a.transpose((0,3,4,2,1,5))\nc = a.transpose((1,2,3,4,5,0))\nposb = a \u003e 0\n```\n\n- Arithmetic test\n\n| Matft                          |     time               | Numpy            |   time               |\n| ------------------------ | ----------------- | ----------------- |----------------- |\n|   `let _ = a+aneg`   |    `596μs`         |     `a+aneg`    |   `1.04ms`         |\n|   `let _ = b+aT`   |    `4.46ms`         |     `b+aT`    |   `4.31ms`         |\n|   `let _ = c+aT`   |    `5.31ms`         |     `c+aT`    |   `2.92ms`         |\n\n- Math test\n\n| Matft                          |     time               | Numpy            |   time               |\n| ------------------------ | ----------------- | ----------------- |----------------- |\n|   `let _ = Matft.math.sin(a)`   |    `2.14ms`         |     `np.sin(a)`    |   `14.7ms`         |\n|   `let _ = Matft.math.sin(b)`   |    `7.02ms`         |     `np.sin(b)`    |   `15.8ms`         |\n|   `let _ = Matft.math.sign(a)`   |    `3.09ms`         |     `np.sign(a)`    |   `1.37ms`         |\n|   `let _ = Matft.math.sign(b)`   |    `8.33ms`         |     `np.sign(b)`    |   `1.42ms`         |\n\n- Bool test\n\n| Matft                          |     time               | Numpy            |   time               |\n| ------------------------ | ----------------- | ----------------- |----------------- |\n|   `let _ = a \u003e 0`   |    `4.63ms`         |     `a \u003e 0`    |   `855μs`         |\n|   `let _ = a \u003e b`   |    `17.8ms`         |     `a \u003e b`    |   `1.83ms`         |\n|   `let _ = a === 0`   |    `4.65ms`         |     `a == 0`    |   `603μs`         |\n|   `let _ = a === b`   |    `19.7ms`         |     `a == b`    |   `1.78ms`         |\n\n- Indexing test\n\n| Matft                          |     time               | Numpy            |   time               |\n| ------------------------ | ----------------- | ----------------- |----------------- |\n|   `let _ = a[posb]`   |    `1.21ms`         |     `a[posb]`    |   `1.29ms`         |\n\n\nMatft achieved almost same performance as Numpy!!!\n\n※Swift's performance test was conducted in release mode\n\nHowever, as you can see the above table, Matft's boolean operation is toooooooo slow...([Issue #18](https://github.com/jjjkkkjjj/Matft/issues/18))\n\nSo, a pull request is very welcome!!\n\n## Installation\n\n### SwiftPM\n\n- Import\n  - Project \u003e Build Setting \u003e + ![Build Setting](https://user-images.githubusercontent.com/16914891/77144994-b0c72280-6aca-11ea-8633-1fb1a13ec74d.png)\n  - Select Rules\n    ![select](https://user-images.githubusercontent.com/16914891/77144995-b1f84f80-6aca-11ea-8f4d-911bd96013cb.png) \n- Update\n  - File \u003eSwift Packages \u003eUpdate to Latest Package versions\n    ![update](https://user-images.githubusercontent.com/16914891/77145225-4367c180-6acb-11ea-98ea-8d7a5a2a669f.png)\n\n**Important!!!** the below installation is outdated. Please install Matft via swiftPM!!!\n\n### Carthage\n\n- Set Cartfile\n\n\t```/bin/bash\n  echo 'github \"jjjkkkjjj/Matft\"' \u003e Cartfile\n\tcarthage update ###or append '--platform ios'\n\t```\n\n- Import Matft.framework made by above process to your project\n\n### CocoaPods\n\n- Create Podfile (Skip if you have already done)\n\n  ```bash\n  pod init\n  ```\n\n- Write `pod 'Matft'` in Podfile such like below\n\n  ```bash\n  target 'your project' do\n    pod 'Matft'\n  end\n  ```\n\n- Install Matft\n\n  ```bash\n  pod install\n  ```\n\n## Contact\n\nFeel free to ask this project or anything via \u003cjunnosuke.kado.git@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjjkkkjjj%2FMatft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjjjkkkjjj%2FMatft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjjkkkjjj%2FMatft/lists"}