{"id":15355846,"url":"https://github.com/fibo/tensor-product","last_synced_at":"2025-04-30T09:41:07.596Z","repository":{"id":65515420,"uuid":"42295052","full_name":"fibo/tensor-product","owner":"fibo","description":"computes the product of tensors","archived":false,"fork":false,"pushed_at":"2018-04-03T21:50:12.000Z","size":69,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T14:51:12.412Z","etag":null,"topics":["algebra","math","tensor"],"latest_commit_sha":null,"homepage":"http://g14n.info/tensor-product","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fibo.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}},"created_at":"2015-09-11T07:47:00.000Z","updated_at":"2018-10-05T23:24:12.000Z","dependencies_parsed_at":"2023-01-26T21:25:12.284Z","dependency_job_id":null,"html_url":"https://github.com/fibo/tensor-product","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Ftensor-product","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Ftensor-product/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Ftensor-product/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Ftensor-product/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibo","download_url":"https://codeload.github.com/fibo/tensor-product/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249484858,"owners_count":21280015,"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","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":["algebra","math","tensor"],"created_at":"2024-10-01T12:26:00.657Z","updated_at":"2025-04-18T11:33:34.695Z","avatar_url":"https://github.com/fibo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tensor-product\n\n\u003e computes the [product of tensors][1]\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\n[![NPM version](https://badge.fury.io/js/tensor-product.svg)](http://badge.fury.io/js/tensor-product) [![Build Status](https://travis-ci.org/fibo/tensor-product.svg?branch=master)](https://travis-ci.org/fibo/tensor-product?branch=master) [![Dependency Status](https://gemnasium.com/fibo/tensor-product.svg)](https://gemnasium.com/fibo/tensor-product)\n\n## Install\n\nWith [npm](https://www.npmjs.com/) do\n\n```\nnpm install tensor-product --save\n```\n\n## Usage\n\nSignature is `(multiplication, leftDim, rightDim, leftData, rightData)` where\n* **multiplication** is a function that defines the scalar operator used\n* **leftDim** and **rightDim** are arrays that define the tensor indices set\n* **leftData** and **rightData** are arrays that define the tensor data set\n\nIt returns the **tensorData** array given by the [product of tensors][1] defined by *leftData* and *rightData*.\n\n### Examples\n\nAll code in the examples below is intended to be contained into a [single file](https://github.com/fibo/tensor-product/blob/master/test.js).\n\nLet's use common real multiplication.\n\n```\nvar tensorProduct = require('tensor-product')\n\nfunction multiplication (a, b) { return a * b }\n\nvar product = tensorProduct.bind(null, multiplication)\n```\n\n### scalar x scalar\n\nA tensor with one index that has a unique value is like a scalar.\nThis case degenerate to scalar multiplication.\n\n```\nvar product_1x1 = product.bind(null, [1], [1])\n\nproduct_1x1([2], [3]) // [6]\n```\n\n### scalar x vector\n\nA tensor with one index which range is greater than one is like a vector.\nThis case is like vector multiplication by a scalar.\n\n```\nvar product_1x2 = product.bind(null, [1], [2])\n\nproduct_1x2([-1], [1, 2]) // [-1, -2]\n```\n\n### vector x vector\n\nThe tensor product of two vectors is a matrix.\n\n```\nvar product_2x2 = product.bind(null, [2], [2])\n\nproduct_2x2([1, 2], [3, 4]) // [3, 4,\n                            //  6, 8]\n```\n\n### matrix x scalar\n\nA tensor with two indices is like a matrix.\nThis case is like matrix multiplication by a scalar.\n\n```\nvar product_2_2x1 = product.bind(null, [2, 2], [1])\n\nproduct_2_2x1( [1, 2,       // [2, 4,\n                3, 4], [2]) //  6, 8]\n```\n\n### scalar x matrix\n\nSimilar to example above, but commuted.\n\n```\nvar product_1x2_2 = product.bind(null, [1], [2, 2])\n\nproduct_1x2_2([2], [1, 2,  // [2, 4,\n                    3, 4]) //  6, 8]\n```\n\n### matrix x matrix\n\nA product tensor of two matrices is a tensor with four indices.\n\n```\nvar product_2_2x2_2 = product.bind(null, [2, 2], [2, 2])\n\nproduct_2_2x2_2([2, 2,\n                 2, 2], [1, 2,\n                         3, 4]) // [2, 2,\n                                //  2, 2, 4, 4,\n                                //        4, 4, 6, 6,\n                                //              6, 6, 8, 8,\n                                //                    8, 8]\n```\n\n## License\n\n[MIT](http://g14n.info/mit-license/)\n\n  [1]: https://en.wikipedia.org/wiki/Tensor_product#Product_of_tensors \"Product of tensors\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Ftensor-product","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibo%2Ftensor-product","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Ftensor-product/lists"}