From efb0275877eae72a948bc43a772ce172dd5f229b Mon Sep 17 00:00:00 2001 From: Ersagun Kuruca Date: Mon, 4 May 2020 00:17:56 +0300 Subject: [PATCH] Fix radius calculation error in Tensor.add method --- src/ts/impl/tensor.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ts/impl/tensor.ts b/src/ts/impl/tensor.ts index 6e48979e..06bc11df 100644 --- a/src/ts/impl/tensor.ts +++ b/src/ts/impl/tensor.ts @@ -39,7 +39,8 @@ export default class Tensor { add(tensor: Tensor): Tensor { this.matrix = this.matrix.map((v, i) => v * this.r + tensor.matrix[i] * tensor.r); - this.r = 2; + this.r = Math.hypot(...this.matrix); + this.matrix = this.matrix.map(v => v / this.r); this.oldTheta = true; return this; }