github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/vector/define/l2norm.go (about)

     1  package define
     2  
     3  import . "github.com/egonelbre/exp/vector/vector"
     4  
     5  func L2NormUnitary[T float32 | float64 | complex64 | complex128](xs []T, n uintptr) T {
     6  	var sumSquares T = 1
     7  	var scale T
     8  
     9  	return Reduce1(
    10  		Vector[T]{Values: xs, Offset: 0, Inc: 1},
    11  		n, func(x T) T {
    12  			if x == 0 {
    13  
    14  			}
    15  			result += x
    16  			return result
    17  		})
    18  }