Is there a method in recent Math.Net to return the SquaredNorm of a vector?

StackOverflow https://stackoverflow.com/questions/22562844

  •  18-06-2023
  •  | 
  •  

In the old version (Iridium) there was a method Vector.SquaredNorm() but in the most recent stable version of Math.Net there is none available.

What method should I use?

有帮助吗?

解决方案

If you want the squared L2-norm (which is what Iridium did if I remember correctly) you can simply square it yourself:

var squaredNorm1 = Math.Pow(v.L2Norm(),2);

Alternatively you can also use dot product which is a bit shorter (and also faster in case you use native providers and the vectors are very large):

var squaredNorm2 = v*v;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top