haydnv / tinychain

A next-gen database + SaaS framework for rapid development and integration of enterprise services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix bug in `Tensor.log()`

annzhukovets opened this issue · comments

commented

When I take log of negative numbers I receive a strange result.
For example
input = [-0.28895986, -0.6805374, -2.8043382, -0.26130563, -1.0145204, -0.46226424, -0.57409143, -0.87136585] output = [-0.28651620147478485, -0.8903620573459765, -1.8430854967317616, -0.9908860025800384, -1.0374829045220275, -0.43846030067423963, -0.03305139265762927, -1.0115898113507216]

The behavior for a float or signed integer in Rust in this case is to return NaN so I'm planning to update Tensor to return an error when asked for the logarithm of a negative real number. The user will have to cast to a Complex type in order to get a valid Complex result.