User described type conversion

I have two script -

  1. linearAlgerbra
  2. Statistics

In lineraAlgebra, I have created a “type Vector float64”. It has a function Sumofsq which takes []Vector has a parameter and returns float64

In Statistics, I have created a “type data []float64”. It has a function vari which takes data has parameters and returns float64

I tried to use Sumofsq function in vari.
But it is giving me error----
cannot use deviations (type data) as type []linearAlgebra.Vector in argument to linearAlgebra.SumOfSquares

here deviation is a variable which stores type data values

I want to know if there is a way to use linearAlgebra.Sumofsq in statistics.go’s vari func

Please show us a SSCCE that, when executed, shows this behaviour.

I am sharing the link of golang playground which generates the same error

From the view of the typechecker the types are distinct.

This is a feature of the typesystem, not a bug.

You need to either simplify types or convert manually between them.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.