diff --git a/README.md b/README.md index b3ac7d5..d73cf77 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ The following all work together to provide a convenient layer of abstraction for * [esg](esg) is the *emergent stochastic / sentence generator* -- parses simple grammars that generate random events (sentences) -- can be a good starting point for generating more complex environments. -* [evec](evec) has `Vec2i` which uses plain `int` X, Y fields, whereas the `mat32` package uses `int32` which are needed for graphics but int is more convenient in models. +* [evec](evec) has `Vec2i` which uses plain `int` X, Y fields, whereas the `math32` package uses `int32` which are needed for graphics but int is more convenient in models. * [popcode](popcode) supports the encoding and decoding of population codes -- distributed representations of numeric quantities across a population of neurons. This is the `ScalarVal` functionality from C++ emergent, but now completely independent of any specific algorithm so it can be used anywhere. diff --git a/decoder/linear.go b/decoder/linear.go index 23472eb..1a68786 100644 --- a/decoder/linear.go +++ b/decoder/linear.go @@ -9,7 +9,7 @@ package decoder import ( "fmt" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/empi/v2/mpi" "github.com/emer/etable/v2/etensor" ) @@ -70,7 +70,7 @@ func IdentityFunc(x float32) float32 { return x } // LogisticFunc implements the standard logistic function. // Its outputs are in the range (0, 1). // Also known as Sigmoid. See https://en.wikipedia.org/wiki/Logistic_function. -func LogisticFunc(x float32) float32 { return 1 / (1 + mat32.FastExp(-x)) } +func LogisticFunc(x float32) float32 { return 1 / (1 + math32.FastExp(-x)) } // LinearUnit has variables for Linear decoder unit type LinearUnit struct { diff --git a/decoder/softmax.go b/decoder/softmax.go index 6e8a309..40a1c87 100644 --- a/decoder/softmax.go +++ b/decoder/softmax.go @@ -15,7 +15,7 @@ import ( "path/filepath" "sort" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/emer" "github.com/emer/empi/v2/mpi" "github.com/emer/etable/v2/etensor" @@ -171,7 +171,7 @@ func (sm *SoftMax) Forward() { for ui := range sm.Units { u := &sm.Units[ui] u.Net -= max - u.Exp = mat32.FastExp(u.Net) + u.Exp = math32.FastExp(u.Net) sum += u.Exp } for ui := range sm.Units { diff --git a/econfig/config.go b/econfig/config.go index f54a058..f288fb8 100644 --- a/econfig/config.go +++ b/econfig/config.go @@ -11,7 +11,7 @@ import ( "os" "reflect" - "cogentcore.org/core/glop/dirs" + "cogentcore.org/core/gox/dirs" "github.com/emer/empi/v2/mpi" ) diff --git a/edge/wrapmindist.go b/edge/wrapmindist.go index ead50d2..e6a4347 100644 --- a/edge/wrapmindist.go +++ b/edge/wrapmindist.go @@ -4,17 +4,17 @@ package edge -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" // WrapMinDist returns the wrapped coordinate value that is closest to ctr // i.e., if going out beyond max is closer, then returns that coordinate // else if going below 0 is closer than not, then returns that coord func WrapMinDist(ci, max, ctr float32) float32 { - nwd := mat32.Abs(ci - ctr) // no-wrap dist - if mat32.Abs((ci+max)-ctr) < nwd { + nwd := math32.Abs(ci - ctr) // no-wrap dist + if math32.Abs((ci+max)-ctr) < nwd { return ci + max } - if mat32.Abs((ci-max)-ctr) < nwd { + if math32.Abs((ci-max)-ctr) < nwd { return ci - max } return ci diff --git a/efuns/gauss.go b/efuns/gauss.go index 4327bda..a7e5da5 100644 --- a/efuns/gauss.go +++ b/efuns/gauss.go @@ -9,20 +9,20 @@ package efuns //go:generate core generate -add-types import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) // GaussVecDistNoNorm returns the gaussian of the distance between two 2D vectors // using given sigma standard deviation, without normalizing area under gaussian // (i.e., max value is 1 at dist = 0) -func GaussVecDistNoNorm(a, b mat32.Vec2, sigma float32) float32 { +func GaussVecDistNoNorm(a, b math32.Vec2, sigma float32) float32 { dsq := a.DistToSquared(b) - return mat32.FastExp((-0.5 * dsq) / (sigma * sigma)) + return math32.FastExp((-0.5 * dsq) / (sigma * sigma)) } // Gauss1DNoNorm returns the gaussian of a given x value, without normalizing // (i.e., max value is 1 at x = 0) func Gauss1DNoNorm(x, sig float32) float32 { x /= sig - return mat32.FastExp(-0.5 * x * x) + return math32.FastExp(-0.5 * x * x) } diff --git a/efuns/logistic.go b/efuns/logistic.go index 9c06875..0e7fd59 100644 --- a/efuns/logistic.go +++ b/efuns/logistic.go @@ -4,9 +4,9 @@ package efuns -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" // Logistic is the logistic (sigmoid) function of x: 1/(1 + e^(-gain*(x-off))) func Logistic(x, gain, off float32) float32 { - return 1.0 / (1.0 + mat32.FastExp(-gain*(x-off))) + return 1.0 / (1.0 + math32.FastExp(-gain*(x-off))) } diff --git a/egui/README.md b/egui/README.md index 1a6c42a..223362e 100644 --- a/egui/README.md +++ b/egui/README.md @@ -18,7 +18,7 @@ func (ss *Sim) ConfigGUI() *gi.Window { // optionally reconfigure the netview: ss.GUI.NetView.Scene().Camera.Pose.Pos.Set(0, 1, 2.75) - ss.GUI.NetView.Scene().Camera.LookAt(mat32.V3(0, 0, 0), mat32.V3(0, 1, 0)) + ss.GUI.NetView.Scene().Camera.LookAt(math32.V3(0, 0, 0), math32.V3(0, 1, 0)) ss.GUI.AddPlots(title, &ss.Logs) // automatically adds all configured plots ``` diff --git a/egui/plots.go b/egui/plots.go index 500b85e..dd7dc3e 100644 --- a/egui/plots.go +++ b/egui/plots.go @@ -9,7 +9,7 @@ import ( "log" "cogentcore.org/core/colors" - "cogentcore.org/core/grr" + "cogentcore.org/core/errors" "github.com/emer/emergent/v2/elog" "github.com/emer/emergent/v2/etime" "github.com/emer/etable/v2/eplot" @@ -53,7 +53,7 @@ func ConfigPlotFromLog(title string, plt *eplot.Plot2D, lg *elog.Logs, key etime cp := plt.SetColParams(item.Name, item.Plot, item.FixMin, item.Range.Min, item.FixMax, item.Range.Max) if item.Color != "" { - cp.Color = grr.Log1(colors.FromString(item.Color, nil)) + cp.Color = errors.Log1(colors.FromString(item.Color, nil)) } cp.TensorIndex = item.TensorIndex cp.ErrCol = item.ErrCol diff --git a/emer/layer.go b/emer/layer.go index 6265a28..0b7f6da 100644 --- a/emer/layer.go +++ b/emer/layer.go @@ -10,7 +10,7 @@ import ( "fmt" "io" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/params" "github.com/emer/emergent/v2/relpos" "github.com/emer/emergent/v2/weights" @@ -87,16 +87,16 @@ type Layer interface { // where the vertical dimension is Y and Z is the depth dimension. However, in the // more "layer-centric" way of thinking about it, it is natural for the width & height // to map onto X and Y, and then Z is left over for stacking vertically. - Pos() mat32.Vec3 + Pos() math32.Vec3 // SetPos sets the 3D position of this layer -- will generally be overwritten by // automatic RelPos setting, unless that doesn't specify a valid relative position. - SetPos(pos mat32.Vec3) + SetPos(pos math32.Vec3) // Size returns the display size of this layer for the 3D view -- see Pos() for general info. // This is multiplied by the RelPos.Scale factor to rescale layer sizes, and takes // into account 2D and 4D layer structures. - Size() mat32.Vec2 + Size() math32.Vec2 // Index returns a 0..n-1 index of the position of the layer within list of layers // in the network. For backprop networks, index position has computational significance. @@ -225,7 +225,7 @@ type Layer interface { // useful when there are multiple projections between two layers. // Returns error on invalid var name. // If the receiving neuron is not connected to the given sending layer or neuron - // then the value is set to mat32.NaN(). + // then the value is set to math32.NaN(). // Returns error on invalid var name or lack of recv prjn (vals always set to nan on prjn err). RecvPrjnValues(vals *[]float32, varNm string, sendLay Layer, sendIndex1D int, prjnType string) error @@ -237,7 +237,7 @@ type Layer interface { // useful when there are multiple projections between two layers. // Returns error on invalid var name. // If the sending neuron is not connected to the given receiving layer or neuron - // then the value is set to mat32.NaN(). + // then the value is set to math32.NaN(). // Returns error on invalid var name or lack of recv prjn (vals always set to nan on prjn err). SendPrjnValues(vals *[]float32, varNm string, recvLay Layer, recvIndex1D int, prjnType string) error diff --git a/emer/network.go b/emer/network.go index 95fc79d..c9080e7 100644 --- a/emer/network.go +++ b/emer/network.go @@ -10,7 +10,7 @@ import ( "io" "cogentcore.org/core/gi" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/params" "github.com/emer/emergent/v2/weights" ) @@ -78,7 +78,7 @@ type Network interface { // UnitVarNames returns a list of variable names available on the units in this network. // This list determines what is shown in the NetView (and the order of vars list). - // Not all layers need to support all variables, but must safely return mat32.NaN() for + // Not all layers need to support all variables, but must safely return math32.NaN() for // unsupported ones. // This is typically a global list so do not modify! UnitVarNames() []string @@ -97,7 +97,7 @@ type Network interface { // SynVarNames returns the names of all the variables on the synapses in this network. // This list determines what is shown in the NetView (and the order of vars list). - // Not all projections need to support all variables, but must safely return mat32.NaN() for + // Not all projections need to support all variables, but must safely return math32.NaN() for // unsupported ones. // This is typically a global list so do not modify! SynVarNames() []string @@ -134,7 +134,7 @@ type Network interface { OpenWtsJSON(filename gi.Filename) error // Bounds returns the minimum and maximum display coordinates of the network for 3D display - Bounds() (min, max mat32.Vec3) + Bounds() (min, max math32.Vec3) // VarRange returns the min / max values for given variable VarRange(varNm string) (min, max float32, err error) diff --git a/emer/prjn.go b/emer/prjn.go index 89d0009..752f400 100644 --- a/emer/prjn.go +++ b/emer/prjn.go @@ -116,7 +116,7 @@ type Prjn interface { // SynVal returns value of given variable name on the synapse // between given send, recv unit indexes (1D, flat indexes). - // Returns mat32.NaN() for access errors. + // Returns math32.NaN() for access errors. SynValue(varNm string, sidx, ridx int) float32 // SetSynVal sets value of given variable name on the synapse diff --git a/erand/erand_test.go b/erand/erand_test.go index 9daf2ec..a9583c3 100644 --- a/erand/erand_test.go +++ b/erand/erand_test.go @@ -8,7 +8,7 @@ import ( "math" "testing" - "cogentcore.org/core/glop/num" + "cogentcore.org/core/gox/num" ) func TestPoisson(t *testing.T) { diff --git a/evec/README.md b/evec/README.md index a9817df..e510d6e 100644 --- a/evec/README.md +++ b/evec/README.md @@ -1,5 +1,5 @@ Docs: [GoDoc](https://pkg.go.dev/github.com/emer/emergent/evec) -Package `evec` has vector types for emergent, including `Vec2i` which is a 2D vector with int values, using the API based on `mat32.Vec2i`. This is distinct from mat32.Vec2i because it uses int instead of int32, and the int is significantly easier to deal with for layer sizing params etc. +Package `evec` has vector types for emergent, including `Vec2i` which is a 2D vector with int values, using the API based on `math32.Vec2i`. This is distinct from math32.Vec2i because it uses int instead of int32, and the int is significantly easier to deal with for layer sizing params etc. diff --git a/evec/vec2i.go b/evec/vec2i.go index bde5edf..30d14e2 100644 --- a/evec/vec2i.go +++ b/evec/vec2i.go @@ -9,12 +9,12 @@ // with modifications needed to suit Cogent Core functionality. // Package evec has vector types for emergent, including Vec2i which is a 2D -// vector with int values, using the API based on mat32.Vec2i. -// This is distinct from mat32.Vec2i because it uses int instead of int32, and +// vector with int values, using the API based on math32.Vec2i. +// This is distinct from math32.Vec2i because it uses int instead of int32, and // the int is significantly easier to deal with for layer sizing params etc. package evec -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" // Vec2i is a 2D vector/point with X and Y int components. type Vec2i struct { @@ -32,24 +32,24 @@ func NewVec2iScalar(s int) Vec2i { return Vec2i{X: s, Y: s} } -// NewVec2iFromVec2Round converts from floating point mat32.Vec2 vector to int, using rounding -func NewVec2iFromVec2Round(v mat32.Vec2) Vec2i { - return Vec2i{int(mat32.Round(v.X)), int(mat32.Round(v.Y))} +// NewVec2iFromVec2Round converts from floating point math32.Vec2 vector to int, using rounding +func NewVec2iFromVec2Round(v math32.Vec2) Vec2i { + return Vec2i{int(math32.Round(v.X)), int(math32.Round(v.Y))} } -// NewVec2iFromVec2Floor converts from floating point mat32.Vec2 vector to int, using floor -func NewVec2iFromVec2Floor(v mat32.Vec2) Vec2i { - return Vec2i{int(mat32.Floor(v.X)), int(mat32.Floor(v.Y))} +// NewVec2iFromVec2Floor converts from floating point math32.Vec2 vector to int, using floor +func NewVec2iFromVec2Floor(v math32.Vec2) Vec2i { + return Vec2i{int(math32.Floor(v.X)), int(math32.Floor(v.Y))} } -// NewVec2iFromVec2Ceil converts from floating point mat32.Vec2 vector to int, using ceil -func NewVec2iFromVec2Ceil(v mat32.Vec2) Vec2i { - return Vec2i{X: int(mat32.Ceil(v.X)), Y: int(mat32.Ceil(v.Y))} +// NewVec2iFromVec2Ceil converts from floating point math32.Vec2 vector to int, using ceil +func NewVec2iFromVec2Ceil(v math32.Vec2) Vec2i { + return Vec2i{X: int(math32.Ceil(v.X)), Y: int(math32.Ceil(v.Y))} } -// ToVec2 returns floating point mat32.Vec2 from int -func (v Vec2i) ToVec2() mat32.Vec2 { - return mat32.V2(float32(v.X), float32(v.Y)) +// ToVec2 returns floating point math32.Vec2 from int +func (v Vec2i) ToVec2() math32.Vec2 { + return math32.V2(float32(v.X), float32(v.Y)) } // IsNil returns true if all values are 0 (uninitialized). diff --git a/looper/manager.go b/looper/manager.go index 5b1fc6b..5323c4d 100644 --- a/looper/manager.go +++ b/looper/manager.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "cogentcore.org/core/glop/indent" + "cogentcore.org/core/gox/indent" "github.com/emer/emergent/v2/etime" ) diff --git a/netparams/io.go b/netparams/io.go index 3b55bc0..df227a4 100644 --- a/netparams/io.go +++ b/netparams/io.go @@ -13,7 +13,7 @@ import ( "os" "cogentcore.org/core/gi" - "cogentcore.org/core/glop/indent" + "cogentcore.org/core/gox/indent" "cogentcore.org/core/grows" "cogentcore.org/core/grows/jsons" "cogentcore.org/core/grows/tomls" diff --git a/netview/data.go b/netview/data.go index 6f815c8..42dff3f 100644 --- a/netview/data.go +++ b/netview/data.go @@ -5,7 +5,7 @@ package netview import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/emer" ) @@ -101,9 +101,9 @@ func (pd *PrjnData) RecordData(nd *NetData) { mn := &nd.SynMinVar[nvi] mx := &nd.SynMaxVar[nvi] for _, vl := range sv { - if !mat32.IsNaN(vl) { - *mn = mat32.Min(*mn, vl) - *mx = mat32.Max(*mx, vl) + if !math32.IsNaN(vl) { + *mn = math32.Min(*mn, vl) + *mx = math32.Max(*mx, vl) } } } diff --git a/netview/events.go b/netview/events.go index fefb466..5b0cbc4 100644 --- a/netview/events.go +++ b/netview/events.go @@ -10,7 +10,7 @@ import ( "cogentcore.org/core/events" "cogentcore.org/core/gi" "cogentcore.org/core/giv" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "cogentcore.org/core/xyz" "cogentcore.org/core/xyzv" "github.com/emer/emergent/v2/emer" @@ -121,10 +121,10 @@ func (sw *Scene) LayerUnitAtPoint(e events.Event) (lay emer.Layer, lx, ly, unInd } nv := sw.NetView nmin, nmax := nv.Net.Bounds() - nsz := nmax.Sub(nmin).Sub(mat32.V3(1, 1, 0)).Max(mat32.V3(1, 1, 1)) - nsc := mat32.V3(1.0/nsz.X, 1.0/nsz.Y, 1.0/nsz.Z) - szc := mat32.Max(nsc.X, nsc.Y) - poff := mat32.V3Scalar(0.5) + nsz := nmax.Sub(nmin).Sub(math32.V3(1, 1, 0)).Max(math32.V3(1, 1, 1)) + nsc := math32.V3(1.0/nsz.X, 1.0/nsz.Y, 1.0/nsz.Z) + szc := math32.Max(nsc.X, nsc.Y) + poff := math32.V3Scalar(0.5) poff.Y = -0.5 for li, lgi := range *laysGp.Children() { lay = nv.Net.Layer(li) @@ -139,7 +139,7 @@ func (sw *Scene) LayerUnitAtPoint(e events.Event) (lay emer.Layer, lx, ly, unInd ray := lo.RayPick(pos) // layer is in XZ plane with norm pointing up in Y axis // offset is 0 in local coordinates - plane := mat32.Plane{Norm: mat32.V3(0, 1, 0), Off: 0} + plane := math32.Plane{Norm: math32.V3(0, 1, 0), Off: 0} pt, ok := ray.IntersectPlane(plane) if !ok || pt.Z > 0 { // Z > 0 means clicked "in front" of plane -- where labels are continue diff --git a/netview/laymesh.go b/netview/laymesh.go index a242b60..63f9cd3 100644 --- a/netview/laymesh.go +++ b/netview/laymesh.go @@ -5,7 +5,7 @@ package netview import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "cogentcore.org/core/vgpu/vshape" "cogentcore.org/core/xyz" "github.com/emer/emergent/v2/emer" @@ -90,7 +90,7 @@ func (lm *LayMesh) Size4D() (nVtx, nIndex int) { return } -func (lm *LayMesh) Set(sc *xyz.Scene, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) Set(sc *xyz.Scene, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { if lm.Lay == nil || lm.Shape.NumDims() == 0 { return // nothing } @@ -120,7 +120,7 @@ func (lm *LayMesh) Set(sc *xyz.Scene, vtxAry, normAry, texAry, clrAry mat32.Arra } -func (lm *LayMesh) Update(sc *xyz.Scene, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) Update(sc *xyz.Scene, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { if lm.Lay == nil || lm.Shape.NumDims() == 0 { return // nothing } @@ -155,7 +155,7 @@ func (lm *LayMesh) Update(sc *xyz.Scene, vtxAry, normAry, texAry, clrAry mat32.A // to the unit cubes -- affects transparency rendering etc var MinUnitHeight = float32(1.0e-6) -func (lm *LayMesh) Set2D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) Set2D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { nz := lm.Shape.Dim(0) nx := lm.Shape.Dim(1) @@ -168,7 +168,7 @@ func (lm *LayMesh) Set2D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrA vtxSz, idxSz := vshape.PlaneN(segs, segs) pidx := 0 // plane index - pos := mat32.Vec3{} + pos := math32.Vec3{} lm.View.ReadLock() for zi := nz - 1; zi >= 0; zi-- { @@ -178,24 +178,24 @@ func (lm *LayMesh) Set2D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrA ioff := pidx * idxSz * 5 x0 := uo + float32(xi) _, scaled, clr, _ := lm.View.UnitValue(lm.Lay, []int{zi, xi}) - v4c := mat32.NewVec4Color(clr) + v4c := math32.NewVec4Color(clr) vshape.SetColor(clrAry, poff, 5*vtxSz, v4c) - ht := 0.5 * mat32.Abs(scaled) + ht := 0.5 * math32.Abs(scaled) if ht < MinUnitHeight { ht = MinUnitHeight } if scaled >= 0 { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, -1, -1, uw, ht, x0, 0, z0, segs, segs, pos) // nz - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, -1, -1, uw, ht, z0, 0, x0+uw, segs, segs, pos) // px - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, uw, ht, z0, 0, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, uw, uw, x0, z0, ht, segs, segs, pos) // py <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, uw, ht, x0, 0, z0+uw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, -1, -1, uw, ht, x0, 0, z0, segs, segs, pos) // nz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, -1, -1, uw, ht, z0, 0, x0+uw, segs, segs, pos) // px + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, uw, ht, z0, 0, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, uw, uw, x0, z0, ht, segs, segs, pos) // py <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, uw, ht, x0, 0, z0+uw, segs, segs, pos) // pz } else { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, 1, -1, uw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, 1, -1, uw, ht, z0, -ht, x0+uw, segs, segs, pos) // px = nx norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, uw, ht, z0, -ht, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, uw, uw, x0, z0, -ht, segs, segs, pos) // ny <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, uw, ht, x0, -ht, z0+uw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, 1, -1, uw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, 1, -1, uw, ht, z0, -ht, x0+uw, segs, segs, pos) // px = nx norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, uw, ht, z0, -ht, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, uw, uw, x0, z0, -ht, segs, segs, pos) // ny <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, uw, ht, x0, -ht, z0+uw, segs, segs, pos) // pz } pidx++ } @@ -203,11 +203,11 @@ func (lm *LayMesh) Set2D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrA lm.View.ReadUnlock() lm.BBoxMu.Lock() - lm.BBox.SetBounds(mat32.V3(0, -0.5, -fnz), mat32.V3(fnx, 0.5, 0)) + lm.BBox.SetBounds(math32.V3(0, -0.5, -fnz), math32.V3(fnx, 0.5, 0)) lm.BBoxMu.Unlock() } -func (lm *LayMesh) Set4D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) Set4D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { npz := lm.Shape.Dim(0) // p = pool npx := lm.Shape.Dim(1) nuz := lm.Shape.Dim(2) // u = unit @@ -233,7 +233,7 @@ func (lm *LayMesh) Set4D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrA vtxSz, idxSz := vshape.PlaneN(segs, segs) pidx := 0 // plane index - pos := mat32.Vec3{} + pos := math32.Vec3{} lm.View.ReadLock() for zpi := npz - 1; zpi >= 0; zpi-- { @@ -247,24 +247,24 @@ func (lm *LayMesh) Set4D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrA ioff := pidx * idxSz * 5 x0 := xp0 + xsc*(uo+float32(xui)) _, scaled, clr, _ := lm.View.UnitValue(lm.Lay, []int{zpi, xpi, zui, xui}) - v4c := mat32.NewVec4Color(clr) + v4c := math32.NewVec4Color(clr) vshape.SetColor(clrAry, poff, 5*vtxSz, v4c) - ht := 0.5 * mat32.Abs(scaled) + ht := 0.5 * math32.Abs(scaled) if ht < MinUnitHeight { ht = MinUnitHeight } if scaled >= 0 { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz } else { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz } pidx++ } @@ -274,6 +274,6 @@ func (lm *LayMesh) Set4D(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrA lm.View.ReadUnlock() lm.BBoxMu.Lock() - lm.BBox.SetBounds(mat32.V3(0, -0.5, -fnpz*fnuz), mat32.V3(fnpx*fnux, 0.5, 0)) + lm.BBox.SetBounds(math32.V3(0, -0.5, -fnpz*fnuz), math32.V3(fnpx*fnux, 0.5, 0)) lm.BBoxMu.Unlock() } diff --git a/netview/layraster.go b/netview/layraster.go index e8eb13f..6631206 100644 --- a/netview/layraster.go +++ b/netview/layraster.go @@ -5,7 +5,7 @@ package netview import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "cogentcore.org/core/vgpu/vshape" "cogentcore.org/core/xyz" ) @@ -42,7 +42,7 @@ func (lm *LayMesh) RasterSize4D() (nVtx, nIndex int) { return } -func (lm *LayMesh) RasterSet2DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) RasterSet2DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { rs := lm.Lay.RepShape() nuz := rs.Dim(0) nux := rs.Dim(1) @@ -74,7 +74,7 @@ func (lm *LayMesh) RasterSet2DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAr vtxSz, idxSz := vshape.PlaneN(segs, segs) pidx := 0 // plane index - pos := mat32.Vec3{} + pos := math32.Vec3{} curRast, _ := lm.View.Data.RasterCtr(-1) @@ -96,24 +96,24 @@ func (lm *LayMesh) RasterSet2DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAr if xi-1 == curRast { xoff++ } - v4c := mat32.NewVec4Color(clr) + v4c := math32.NewVec4Color(clr) vshape.SetColor(clrAry, poff, 5*vtxSz, v4c) - ht := htsc * mat32.Abs(scaled) + ht := htsc * math32.Abs(scaled) if ht < MinUnitHeight { ht = MinUnitHeight } if scaled >= 0 { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz } else { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz } pidx++ } @@ -121,11 +121,11 @@ func (lm *LayMesh) RasterSet2DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAr lm.View.ReadUnlock() lm.BBoxMu.Lock() - lm.BBox.SetBounds(mat32.V3(0, -0.5, -fnz), mat32.V3(fnx, 0.5, 0)) + lm.BBox.SetBounds(math32.V3(0, -0.5, -fnz), math32.V3(fnx, 0.5, 0)) lm.BBoxMu.Unlock() } -func (lm *LayMesh) RasterSet2DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) RasterSet2DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { rs := lm.Lay.RepShape() nuz := rs.Dim(0) nux := rs.Dim(1) @@ -157,7 +157,7 @@ func (lm *LayMesh) RasterSet2DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAr vtxSz, idxSz := vshape.PlaneN(segs, segs) pidx := 0 // plane index - pos := mat32.Vec3{} + pos := math32.Vec3{} curRast, _ := lm.View.Data.RasterCtr(-1) @@ -179,24 +179,24 @@ func (lm *LayMesh) RasterSet2DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAr if zi-1 == curRast { zoff = 0 } - v4c := mat32.NewVec4Color(clr) + v4c := math32.NewVec4Color(clr) vshape.SetColor(clrAry, poff, 5*vtxSz, v4c) - ht := htsc * mat32.Abs(scaled) + ht := htsc * math32.Abs(scaled) if ht < MinUnitHeight { ht = MinUnitHeight } if scaled >= 0 { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz } else { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz } pidx++ } @@ -204,11 +204,11 @@ func (lm *LayMesh) RasterSet2DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAr lm.View.ReadUnlock() lm.BBoxMu.Lock() - lm.BBox.SetBounds(mat32.V3(0, -0.5, -fnz), mat32.V3(fnx, 0.5, 0)) + lm.BBox.SetBounds(math32.V3(0, -0.5, -fnz), math32.V3(fnx, 0.5, 0)) lm.BBoxMu.Unlock() } -func (lm *LayMesh) RasterSet4DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) RasterSet4DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { rs := lm.Lay.RepShape() npz := rs.Dim(0) // p = pool npx := rs.Dim(1) @@ -255,7 +255,7 @@ func (lm *LayMesh) RasterSet4DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAr vtxSz, idxSz := vshape.PlaneN(segs, segs) pidx := 0 // plane index - pos := mat32.Vec3{} + pos := math32.Vec3{} curRast, _ := lm.View.Data.RasterCtr(-1) @@ -281,24 +281,24 @@ func (lm *LayMesh) RasterSet4DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAr if xi-1 == curRast { xoff++ } - v4c := mat32.NewVec4Color(clr) + v4c := math32.NewVec4Color(clr) vshape.SetColor(clrAry, poff, 5*vtxSz, v4c) - ht := htsc * mat32.Abs(scaled) + ht := htsc * math32.Abs(scaled) if ht < MinUnitHeight { ht = MinUnitHeight } if scaled >= 0 { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz } else { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz } pidx++ } @@ -308,11 +308,11 @@ func (lm *LayMesh) RasterSet4DX(sc *xyz.Scene, init bool, vtxAry, normAry, texAr lm.View.ReadUnlock() lm.BBoxMu.Lock() - lm.BBox.SetBounds(mat32.V3(0, -0.5, -fnpoz*fnuz), mat32.V3(fnpox*fnux, 0.5, 0)) + lm.BBox.SetBounds(math32.V3(0, -0.5, -fnpoz*fnuz), math32.V3(fnpox*fnux, 0.5, 0)) lm.BBoxMu.Unlock() } -func (lm *LayMesh) RasterSet4DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, idxAry mat32.ArrayU32) { +func (lm *LayMesh) RasterSet4DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32) { rs := lm.Lay.RepShape() npz := rs.Dim(0) // p = pool npx := rs.Dim(1) @@ -359,7 +359,7 @@ func (lm *LayMesh) RasterSet4DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAr vtxSz, idxSz := vshape.PlaneN(segs, segs) pidx := 0 // plane index - pos := mat32.Vec3{} + pos := math32.Vec3{} curRast, _ := lm.View.Data.RasterCtr(-1) @@ -385,24 +385,24 @@ func (lm *LayMesh) RasterSet4DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAr if zi-1 == curRast { zoff = 0 } - v4c := mat32.NewVec4Color(clr) + v4c := math32.NewVec4Color(clr) vshape.SetColor(clrAry, poff, 5*vtxSz, v4c) - ht := htsc * mat32.Abs(scaled) + ht := htsc * math32.Abs(scaled) if ht < MinUnitHeight { ht = MinUnitHeight } if scaled >= 0 { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, -1, -1, xuw, ht, x0, 0, z0, segs, segs, pos) // nz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, -1, -1, zuw, ht, z0, 0, x0+xuw, segs, segs, pos) // px + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, 0, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, ht, segs, segs, pos) // py <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, 0, z0+zuw, segs, segs, pos) // pz } else { - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, mat32.Z, mat32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, mat32.X, mat32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- - vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, mat32.X, mat32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff, ioff, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0, segs, segs, pos) // nz = pz norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+1*vtxSz, ioff+1*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0+xuw, segs, segs, pos) // px = nx norm + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+2*vtxSz, ioff+2*idxSz, math32.Z, math32.Y, 1, -1, zuw, ht, z0, -ht, x0, segs, segs, pos) // nx + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+3*vtxSz, ioff+3*idxSz, math32.X, math32.Z, 1, 1, xuw, zuw, x0, z0, -ht, segs, segs, pos) // ny <- + vshape.SetPlane(vtxAry, normAry, texAry, idxAry, poff+4*vtxSz, ioff+4*idxSz, math32.X, math32.Y, 1, -1, xuw, ht, x0, -ht, z0+zuw, segs, segs, pos) // pz } pidx++ } @@ -412,6 +412,6 @@ func (lm *LayMesh) RasterSet4DZ(sc *xyz.Scene, init bool, vtxAry, normAry, texAr lm.View.ReadUnlock() lm.BBoxMu.Lock() - lm.BBox.SetBounds(mat32.V3(0, -0.5, -fnpoz*fnuz), mat32.V3(fnpox*fnux, 0.5, 0)) + lm.BBox.SetBounds(math32.V3(0, -0.5, -fnpoz*fnuz), math32.V3(fnpox*fnux, 0.5, 0)) lm.BBoxMu.Unlock() } diff --git a/netview/netdata.go b/netview/netdata.go index f50a000..c043ac4 100644 --- a/netview/netdata.go +++ b/netview/netdata.go @@ -18,7 +18,7 @@ import ( "strings" "cogentcore.org/core/gi" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/emer" "github.com/emer/emergent/v2/ringidx" "github.com/emer/etable/v2/eplot" @@ -264,9 +264,9 @@ func (nd *NetData) Record(ctrs string, rastCtr, rastMax int) { lay.UnitValues(&dvals, vnm, di) for ui := range dvals { vl := dvals[ui] - if !mat32.IsNaN(vl) { - *mn = mat32.Min(*mn, vl) - *mx = mat32.Max(*mx, vl) + if !math32.IsNaN(vl) { + *mn = math32.Min(*mn, vl) + *mx = math32.Max(*mx, vl) } } } @@ -299,8 +299,8 @@ func (nd *NetData) UpdateUnVarRange() { mmidx := ridx * vlen mn := nd.UnMinPer[mmidx+vi] mx := nd.UnMaxPer[mmidx+vi] - *vmn = mat32.Min(*vmn, mn) - *vmx = mat32.Max(*vmx, mx) + *vmn = math32.Min(*vmn, mn) + *vmx = math32.Max(*vmx, mx) } } } @@ -430,7 +430,7 @@ func (nd *NetData) UnitValueIndex(laynm string, vnm string, uidx1d int, ridx int nvu := vlen * nd.MaxData * nu idx := ridx*nvu + vi*nd.MaxData*nu + di*nu + uidx1d val := ld.Data[idx] - if mat32.IsNaN(val) { + if math32.IsNaN(val) { return 0, false } return val, true @@ -582,7 +582,7 @@ func (nd *NetData) SaveJSON(filename gi.Filename) error { //gti:add func (nd *NetData) ReadJSON(r io.Reader) error { dec := json.NewDecoder(r) err := dec.Decode(nd) // this is way to do it on reader instead of bytes - nan := mat32.NaN() + nan := math32.NaN() for _, ld := range nd.LayData { for i := range ld.Data { if ld.Data[i] == NaNSub { @@ -604,7 +604,7 @@ const NaNSub = -1.11e-37 func (nd *NetData) WriteJSON(w io.Writer) error { for _, ld := range nd.LayData { for i := range ld.Data { - if mat32.IsNaN(ld.Data[i]) { + if math32.IsNaN(ld.Data[i]) { ld.Data[i] = NaNSub } } diff --git a/netview/netview.go b/netview/netview.go index ef46ac8..a24aedf 100644 --- a/netview/netview.go +++ b/netview/netview.go @@ -26,7 +26,7 @@ import ( "cogentcore.org/core/giv" "cogentcore.org/core/icons" "cogentcore.org/core/ki" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "cogentcore.org/core/styles" "cogentcore.org/core/texteditor" "cogentcore.org/core/xyz" @@ -235,7 +235,7 @@ func (nv *NetView) UpdateImpl() { } } if vp.ZeroCtr && !vp.Range.FixMin && !vp.Range.FixMax { - bmax := mat32.Max(mat32.Abs(vp.Range.Max), mat32.Abs(vp.Range.Min)) + bmax := math32.Max(math32.Abs(vp.Range.Max), math32.Abs(vp.Range.Min)) if !needUpdate { if vp.Range.Max != bmax || vp.Range.Min != -bmax { needUpdate = true @@ -645,10 +645,10 @@ func (nv *NetView) ViewConfig() { laysGp.ConfigChildren(layConfig) nmin, nmax := nv.Net.Bounds() - nsz := nmax.Sub(nmin).Sub(mat32.V3(1, 1, 0)).Max(mat32.V3(1, 1, 1)) - nsc := mat32.V3(1.0/nsz.X, 1.0/nsz.Y, 1.0/nsz.Z) - szc := mat32.Max(nsc.X, nsc.Y) - poff := mat32.V3Scalar(0.5) + nsz := nmax.Sub(nmin).Sub(math32.V3(1, 1, 0)).Max(math32.V3(1, 1, 1)) + nsc := math32.V3(1.0/nsz.X, 1.0/nsz.Y, 1.0/nsz.Z) + szc := math32.Max(nsc.X, nsc.Y) + poff := math32.V3Scalar(0.5) poff.Y = -0.5 for li, lgi := range *laysGp.Children() { ly := nv.Net.Layer(li) @@ -678,7 +678,7 @@ func (nv *NetView) ViewConfig() { txt.Defaults() txt.NetView = nv txt.SetText(ly.Name()) - txt.Pose.Scale = mat32.V3Scalar(nv.Params.LayNmSize).Div(lg.Pose.Scale) + txt.Pose.Scale = math32.V3Scalar(nv.Params.LayNmSize).Div(lg.Pose.Scale) txt.Styles.Background = colors.C(colors.Transparent) txt.Styles.Text.Align = styles.Start txt.Styles.Text.AlignV = styles.Start @@ -694,7 +694,7 @@ func (nv *NetView) ViewDefaults() { se.Camera.Pose.Pos.Set(0, 1.5, 2.5) // more "top down" view shows more of layers // vs.Camera.Pose.Pos.Set(0, 1, 2.75) // more "head on" for larger / deeper networks se.Camera.Near = 0.1 - se.Camera.LookAt(mat32.V3(0, 0, 0), mat32.V3(0, 1, 0)) + se.Camera.LookAt(math32.V3(0, 0, 0), math32.V3(0, 1, 0)) // todo: // vs.BgColor = gi.Prefs.Colors.Background xyz.NewAmbientLight(se, "ambient", 0.1, xyz.DirectSun) @@ -783,7 +783,7 @@ func (nv *NetView) UnitValColor(lay emer.Layer, idx1d int, raw float32, hasval b var op float32 if nv.CurVarParams.ZeroCtr { scaled = float32(2*norm - 1) - op = (nv.Params.ZeroAlpha + (1-nv.Params.ZeroAlpha)*mat32.Abs(scaled)) + op = (nv.Params.ZeroAlpha + (1-nv.Params.ZeroAlpha)*math32.Abs(scaled)) } else { scaled = float32(norm) op = (nv.Params.ZeroAlpha + (1-nv.Params.ZeroAlpha)*0.8) // no meaningful alpha -- just set at 80\% diff --git a/params/io.go b/params/io.go index 5ac7e49..5a788e4 100644 --- a/params/io.go +++ b/params/io.go @@ -15,7 +15,7 @@ import ( "sort" "cogentcore.org/core/gi" - "cogentcore.org/core/glop/indent" + "cogentcore.org/core/gox/indent" "cogentcore.org/core/grows" "cogentcore.org/core/grows/jsons" "cogentcore.org/core/grows/tomls" diff --git a/params/tweak.go b/params/tweak.go index c6f39c5..4290854 100644 --- a/params/tweak.go +++ b/params/tweak.go @@ -11,15 +11,15 @@ import ( "strings" "cogentcore.org/core/laser" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "golang.org/x/exp/maps" ) func tweakValue(msd, fact, exp10 float32, isRmdr bool) float32 { if isRmdr { - return mat32.Truncate(msd+fact*mat32.Pow(10, exp10), 3) + return math32.Truncate(msd+fact*math32.Pow(10, exp10), 3) } - return mat32.Truncate(fact*mat32.Pow(10, exp10), 3) + return math32.Truncate(fact*math32.Pow(10, exp10), 3) } // Tweak returns parameters to try below and above the given value. @@ -28,19 +28,19 @@ func tweakValue(msd, fact, exp10 float32, isRmdr bool) float32 { // These apply to the 2nd significant digit (remainder after most significant digit) // if that is present in the original value. func Tweak(v float32, log, incr bool) []float32 { - ex := mat32.Floor(mat32.Log10(v)) - base := mat32.Pow(10, ex) - basem1 := mat32.Pow(10, ex-1) - fact := mat32.Round(v / base) + ex := math32.Floor(math32.Log10(v)) + base := math32.Pow(10, ex) + basem1 := math32.Pow(10, ex-1) + fact := math32.Round(v / base) msd := tweakValue(0, fact, ex, false) - rmdr := mat32.Round((v - msd) / basem1) + rmdr := math32.Round((v - msd) / basem1) var vals []float32 sv := fact isRmdr := false if rmdr != 0 { if rmdr < 0 { msd = tweakValue(0, fact-1, ex, false) - rmdr = mat32.Round((v - msd) / basem1) + rmdr = math32.Round((v - msd) / basem1) } sv = rmdr ex-- diff --git a/patgen/permuted.go b/patgen/permuted.go index b76a17d..ddfa05f 100644 --- a/patgen/permuted.go +++ b/patgen/permuted.go @@ -10,7 +10,7 @@ import ( "log" "math" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/erand" "github.com/emer/etable/v2/etensor" "github.com/emer/etable/v2/metric" @@ -140,8 +140,8 @@ func RowVsPrevDist32(tsr *etensor.Float32, row int, fun metric.Func32) (min, max for i := 0; i <= row-1; i++ { crow := tsr.SubSpace([]int{i}).(*etensor.Float32) dst := fun(lrow.Values, crow.Values) - min = mat32.Min(min, dst) - max = mat32.Max(max, dst) + min = math32.Min(min, dst) + max = math32.Max(max, dst) } return } diff --git a/popcode/popcode1d.go b/popcode/popcode1d.go index 9d1f09b..92b2ad3 100644 --- a/popcode/popcode1d.go +++ b/popcode/popcode1d.go @@ -9,7 +9,7 @@ package popcode import ( "sort" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) type PopCodes int @@ -97,7 +97,7 @@ func (pc *OneD) Encode(pat *[]float32, val float32, n int, add bool) { *pat = make([]float32, n) } if pc.Clip { - val = mat32.Clamp(val, pc.Min, pc.Max) + val = math32.Clamp(val, pc.Min, pc.Max) } rng := pc.Max - pc.Min gnrm := 1 / (rng * pc.Sigma) @@ -108,9 +108,9 @@ func (pc *OneD) Encode(pat *[]float32, val float32, n int, add bool) { switch pc.Code { case GaussBump: dist := gnrm * (trg - val) - act = mat32.Exp(-(dist * dist)) + act = math32.Exp(-(dist * dist)) case Localist: - dist := mat32.Abs(trg - val) + dist := math32.Abs(trg - val) if dist > incr { act = 0 } else { @@ -146,7 +146,7 @@ func (pc *OneD) Decode(pat []float32) float32 { avg += trg * act sum += act } - sum = mat32.Max(sum, pc.MinSum) + sum = math32.Max(sum, pc.MinSum) avg /= sum return avg } @@ -229,7 +229,7 @@ func (pc *OneD) DecodeNPeaks(pat []float32, nvals, width int) []float32 { avg += trg * act sum += act } - sum = mat32.Max(sum, pc.MinSum) + sum = math32.Max(sum, pc.MinSum) vals[i] = avg / sum } diff --git a/popcode/popcode2d.go b/popcode/popcode2d.go index 1e5d20f..56605a9 100644 --- a/popcode/popcode2d.go +++ b/popcode/popcode2d.go @@ -9,7 +9,7 @@ import ( "log" "sort" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/etable/v2/etensor" ) @@ -23,13 +23,13 @@ type TwoD struct { Code PopCodes // minimum value representable on each dim -- for GaussBump, typically include extra to allow mean with activity on either side to represent the lowest value you want to encode - Min mat32.Vec2 + Min math32.Vec2 // maximum value representable on each dim -- for GaussBump, typically include extra to allow mean with activity on either side to represent the lowest value you want to encode - Max mat32.Vec2 + Max math32.Vec2 // sigma parameters of a gaussian specifying the tuning width of the coarse-coded units, in normalized 0-1 range - Sigma mat32.Vec2 `default:"0.2"` + Sigma math32.Vec2 `default:"0.2"` // ensure that encoded and decoded value remains within specified range -- generally not useful with wrap Clip bool @@ -78,7 +78,7 @@ func (pc *TwoD) SetRange(min, max, sigma float32) { // If add == false (use Set const for clarity), values are set to pattern // else if add == true (Add), then values are added to any existing, // for encoding additional values in same pattern. -func (pc *TwoD) Encode(pat etensor.Tensor, val mat32.Vec2, add bool) error { +func (pc *TwoD) Encode(pat etensor.Tensor, val math32.Vec2, add bool) error { if pat.NumDims() != 2 { err := fmt.Errorf("popcode.TwoD Encode: pattern must have 2 dimensions") log.Println(err) @@ -93,10 +93,10 @@ func (pc *TwoD) Encode(pat etensor.Tensor, val mat32.Vec2, add bool) error { err := pc.EncodeImpl(pat, val, add) // always render first ev := val // relative to min - if pc.WrapX && mat32.Abs(pc.Max.X-val.X) < sr.X { // has significant vals near max + if pc.WrapX && math32.Abs(pc.Max.X-val.X) < sr.X { // has significant vals near max ev.X = pc.Min.X - (pc.Max.X - val.X) // wrap extra above max around to min } - if pc.WrapY && mat32.Abs(pc.Max.Y-val.Y) < sr.Y { + if pc.WrapY && math32.Abs(pc.Max.Y-val.Y) < sr.Y { ev.Y = pc.Min.Y - (pc.Max.Y - val.Y) } if ev != val { @@ -104,10 +104,10 @@ func (pc *TwoD) Encode(pat etensor.Tensor, val mat32.Vec2, add bool) error { } // pev := ev ev = val - if pc.WrapX && mat32.Abs(val.X-pc.Min.X) < sr.X { // has significant vals near min + if pc.WrapX && math32.Abs(val.X-pc.Min.X) < sr.X { // has significant vals near min ev.X = pc.Max.X - (val.X - pc.Min.X) // wrap extra below min around to max } - if pc.WrapY && mat32.Abs(val.Y-pc.Min.Y) < sr.Y { + if pc.WrapY && math32.Abs(val.Y-pc.Min.Y) < sr.Y { ev.Y = pc.Max.Y - (val.Y - pc.Min.Y) } if ev != val { @@ -119,27 +119,27 @@ func (pc *TwoD) Encode(pat etensor.Tensor, val mat32.Vec2, add bool) error { } // EncodeImpl is the implementation of encoding -- e.g., used twice for Wrap -func (pc *TwoD) EncodeImpl(pat etensor.Tensor, val mat32.Vec2, add bool) error { +func (pc *TwoD) EncodeImpl(pat etensor.Tensor, val math32.Vec2, add bool) error { rng := pc.Max.Sub(pc.Min) - gnrm := mat32.V2Scalar(1).Div(rng.Mul(pc.Sigma)) + gnrm := math32.V2Scalar(1).Div(rng.Mul(pc.Sigma)) ny := pat.Dim(0) nx := pat.Dim(1) - nf := mat32.V2(float32(nx-1), float32(ny-1)) + nf := math32.V2(float32(nx-1), float32(ny-1)) incr := rng.Div(nf) for yi := 0; yi < ny; yi++ { for xi := 0; xi < nx; xi++ { - fi := mat32.V2(float32(xi), float32(yi)) + fi := math32.V2(float32(xi), float32(yi)) trg := pc.Min.Add(incr.Mul(fi)) act := float32(0) switch pc.Code { case GaussBump: dist := trg.Sub(val).Mul(gnrm) - act = mat32.Exp(-dist.LengthSq()) + act = math32.Exp(-dist.LengthSq()) case Localist: dist := trg.Sub(val) - dist.X = mat32.Abs(dist.X) - dist.Y = mat32.Abs(dist.Y) + dist.X = math32.Abs(dist.X) + dist.Y = math32.Abs(dist.Y) if dist.X > incr.X || dist.Y > incr.Y { act = 0 } else { @@ -162,11 +162,11 @@ func (pc *TwoD) EncodeImpl(pat etensor.Tensor, val mat32.Vec2, add bool) error { // Decode decodes 2D value from a pattern of activation // as the activation-weighted-average of the unit's preferred // tuning values. -func (pc *TwoD) Decode(pat etensor.Tensor) (mat32.Vec2, error) { +func (pc *TwoD) Decode(pat etensor.Tensor) (math32.Vec2, error) { if pat.NumDims() != 2 { err := fmt.Errorf("popcode.TwoD Decode: pattern must have 2 dimensions") log.Println(err) - return mat32.Vec2{}, err + return math32.Vec2{}, err } if pc.WrapX || pc.WrapY { ny := pat.Dim(0) @@ -186,7 +186,7 @@ func (pc *TwoD) Decode(pat etensor.Tensor) (mat32.Vec2, error) { xs[xi] += act * xdiv } } - var val mat32.Vec2 + var val math32.Vec2 switch { case pc.WrapX && pc.WrapY: dx := Ring{} @@ -253,12 +253,12 @@ func (pc *TwoD) Decode(pat etensor.Tensor) (mat32.Vec2, error) { } // DecodeImpl does direct decoding of x, y simultaneously -- for non-wrap -func (pc *TwoD) DecodeImpl(pat etensor.Tensor) (mat32.Vec2, error) { - avg := mat32.Vec2{} +func (pc *TwoD) DecodeImpl(pat etensor.Tensor) (math32.Vec2, error) { + avg := math32.Vec2{} rng := pc.Max.Sub(pc.Min) ny := pat.Dim(0) nx := pat.Dim(1) - nf := mat32.V2(float32(nx-1), float32(ny-1)) + nf := math32.V2(float32(nx-1), float32(ny-1)) incr := rng.Div(nf) sum := float32(0) for yi := 0; yi < ny; yi++ { @@ -268,13 +268,13 @@ func (pc *TwoD) DecodeImpl(pat etensor.Tensor) (mat32.Vec2, error) { if act < pc.Thr { act = 0 } - fi := mat32.V2(float32(xi), float32(yi)) + fi := math32.V2(float32(xi), float32(yi)) trg := pc.Min.Add(incr.Mul(fi)) avg = avg.Add(trg.MulScalar(act)) sum += act } } - sum = mat32.Max(sum, pc.MinSum) + sum = math32.Max(sum, pc.MinSum) return avg.DivScalar(sum), nil } @@ -284,7 +284,7 @@ func (pc *TwoD) DecodeImpl(pat etensor.Tensor) (mat32.Vec2, error) { // vals slice will be constructed if len != n func (pc *TwoD) Values(valsX, valsY *[]float32, nx, ny int) { rng := pc.Max.Sub(pc.Min) - nf := mat32.V2(float32(nx-1), float32(ny-1)) + nf := math32.V2(float32(nx-1), float32(ny-1)) incr := rng.Div(nf) // X @@ -312,7 +312,7 @@ func (pc *TwoD) Values(valsX, valsY *[]float32, nx, ny int) { // accumulate (0 = localist, single points, 1 = +/- 1 points on // either side in a square around central point, etc) // Allocates a temporary slice of size pat, and sorts that: relatively expensive -func (pc *TwoD) DecodeNPeaks(pat etensor.Tensor, nvals, width int) ([]mat32.Vec2, error) { +func (pc *TwoD) DecodeNPeaks(pat etensor.Tensor, nvals, width int) ([]math32.Vec2, error) { if pat.NumDims() != 2 { err := fmt.Errorf("popcode.TwoD DecodeNPeaks: pattern must have 2 dimensions") log.Println(err) @@ -321,7 +321,7 @@ func (pc *TwoD) DecodeNPeaks(pat etensor.Tensor, nvals, width int) ([]mat32.Vec2 rng := pc.Max.Sub(pc.Min) ny := pat.Dim(0) nx := pat.Dim(1) - nf := mat32.V2(float32(nx-1), float32(ny-1)) + nf := math32.V2(float32(nx-1), float32(ny-1)) incr := rng.Div(nf) type navg struct { @@ -363,9 +363,9 @@ func (pc *TwoD) DecodeNPeaks(pat etensor.Tensor, nvals, width int) ([]mat32.Vec2 return avgs[i].avg > avgs[j].avg }) - vals := make([]mat32.Vec2, nvals) + vals := make([]math32.Vec2, nvals) for i := range vals { - avg := mat32.Vec2{} + avg := math32.Vec2{} sum := float32(0) mxi := avgs[i].x myi := avgs[i].y @@ -384,13 +384,13 @@ func (pc *TwoD) DecodeNPeaks(pat etensor.Tensor, nvals, width int) ([]mat32.Vec2 if act < pc.Thr { act = 0 } - fi := mat32.V2(float32(x), float32(y)) + fi := math32.V2(float32(x), float32(y)) trg := pc.Min.Add(incr.Mul(fi)) avg = avg.Add(trg.MulScalar(act)) sum += act } } - sum = mat32.Max(sum, pc.MinSum) + sum = math32.Max(sum, pc.MinSum) vals[i] = avg.DivScalar(sum) } diff --git a/popcode/popcode_test.go b/popcode/popcode_test.go index 3fabce9..5ad50c8 100644 --- a/popcode/popcode_test.go +++ b/popcode/popcode_test.go @@ -7,7 +7,7 @@ package popcode import ( "testing" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/etable/v2/etensor" ) @@ -18,7 +18,7 @@ const difTolMulti = float32(1.0e-2) func CmprFloats(out, cor []float32, msg string, t *testing.T) { for i := range out { - dif := mat32.Abs(out[i] - cor[i]) + dif := math32.Abs(out[i] - cor[i]) if dif > difTol { // allow for small numerical diffs t.Errorf("%v err: out: %v, cor: %v, dif: %v\n", msg, out[i], cor[i], dif) } @@ -46,7 +46,7 @@ func TestPopCode1D(t *testing.T) { val := pc.Decode(pat) //fmt.Printf("decode pat for 0.5: %v\n", val) - if mat32.Abs(val-0.5) > difTol { + if math32.Abs(val-0.5) > difTol { t.Errorf("did not decode properly: val: %v != 0.5", val) } } @@ -68,11 +68,11 @@ func TestPopCode1DMulti(t *testing.T) { // fmt.Printf("decode pat for 0.25, 0.75: %v\n", vals) for _, val := range vals { if val > 0.5 { - if mat32.Abs(val-0.9) > difTolMulti { + if math32.Abs(val-0.9) > difTolMulti { t.Errorf("did not decode properly: val: %v != 0.9", val) } } else { - if mat32.Abs(val-0.1) > difTolMulti { + if math32.Abs(val-0.1) > difTolMulti { t.Errorf("did not decode properly: val: %v != 0.1", val) } } @@ -93,7 +93,7 @@ func TestPopCode2D(t *testing.T) { var pat etensor.Float32 pat.SetShape([]int{11, 11}, nil, nil) - pc.Encode(&pat, mat32.V2(0.3, 0.9), Set) + pc.Encode(&pat, math32.V2(0.3, 0.9), Set) // fmt.Printf("pat for 0.5: %v\n", pat) corPat := []float32{8.7642576e-08, 5.0434767e-07, 1.7603463e-06, 3.7266532e-06, 4.7851167e-06, 3.7266532e-06, 1.7603463e-06, 5.0434767e-07, 8.7642576e-08, 9.237448e-09, 5.905302e-10, 2.2603292e-06, 1.3007299e-05, 4.5399953e-05, 9.611166e-05, 0.0001234098, 9.611166e-05, 4.5399953e-05, 1.3007299e-05, 2.2603292e-06, 2.3823696e-07, 1.5229979e-08, 3.53575e-05, 0.00020346837, 0.0007101748, 0.0015034394, 0.0019304542, 0.0015034394, 0.0007101748, 0.00020346837, 3.53575e-05, 3.7266532e-06, 2.3823696e-07, 0.00033546257, 0.0019304551, 0.0067379503, 0.014264241, 0.018315647, 0.014264241, 0.006737947, 0.001930456, 0.00033546257, 3.53575e-05, 2.2603292e-06, 0.0019304542, 0.011109002, 0.038774215, 0.08208501, 0.10539925, 0.08208501, 0.038774207, 0.011109007, 0.0019304542, 0.00020346837, 1.3007299e-05, 0.006737947, 0.038774207, 0.1353353, 0.28650483, 0.3678795, 0.28650483, 0.13533528, 0.038774226, 0.006737947, 0.0007101748, 4.5399953e-05, 0.014264233, 0.08208501, 0.28650486, 0.6065308, 0.77880096, 0.6065308, 0.2865048, 0.08208503, 0.014264233, 0.0015034394, 9.611166e-05, 0.018315637, 0.10539923, 0.36787945, 0.7788008, 1, 0.7788008, 0.3678794, 0.10539925, 0.018315637, 0.0019304542, 0.0001234098, 0.014264233, 0.08208499, 0.28650478, 0.6065306, 0.77880067, 0.6065306, 0.2865047, 0.08208499, 0.014264233, 0.0015034394, 9.611166e-05, 0.0067379437, 0.03877419, 0.13533522, 0.28650466, 0.36787927, 0.28650466, 0.13533519, 0.038774196, 0.0067379437, 0.0007101744, 4.5399953e-05, 0.0019304542, 0.011109002, 0.038774207, 0.08208499, 0.10539923, 0.08208499, 0.038774196, 0.011109002, 0.0019304542, 0.00020346837, 1.3007299e-05} @@ -105,10 +105,10 @@ func TestPopCode2D(t *testing.T) { if err != nil { t.Error(err) } - if mat32.Abs(val.X-0.3) > difTol { + if math32.Abs(val.X-0.3) > difTol { t.Errorf("did not decode properly: val: %v != 0.3", val) } - if mat32.Abs(val.Y-0.9) > difTol { + if math32.Abs(val.Y-0.9) > difTol { t.Errorf("did not decode properly: val: %v != 0.9", val) } } @@ -120,8 +120,8 @@ func TestPopCode2DMulti(t *testing.T) { var pat etensor.Float32 // note: usually you'd use a larger pattern size for multiple values pat.SetShape([]int{11, 11}, nil, nil) - pc.Encode(&pat, mat32.V2(0.1, 0.9), Set) - pc.Encode(&pat, mat32.V2(0.9, 0.1), Add) + pc.Encode(&pat, math32.V2(0.1, 0.9), Set) + pc.Encode(&pat, math32.V2(0.9, 0.1), Add) // fmt.Printf("pat for 0.1, 0.9: %v\n", pat) @@ -137,13 +137,13 @@ func TestPopCode2DMulti(t *testing.T) { // fmt.Printf("decode pat for 0.1, 0.9; 0.9, 0.1: %v\n", vals) for _, valv := range vals { for d := 0; d < 2; d++ { - val := valv.Dim(mat32.Dims(d)) + val := valv.Dim(math32.Dims(d)) if val > 0.5 { - if mat32.Abs(val-0.9) > difTolMulti { + if math32.Abs(val-0.9) > difTolMulti { t.Errorf("did not decode properly: val: %v != 0.9", val) } } else { - if mat32.Abs(val-0.1) > difTolMulti { + if math32.Abs(val-0.1) > difTolMulti { t.Errorf("did not decode properly: val: %v != 0.1", val) } } @@ -172,7 +172,7 @@ func TestRing(t *testing.T) { // fmt.Printf("pat for 180: %v\n", pat) val := pc.Decode(pat) // fmt.Printf("decode pat for 180: %v\n", val) - if mat32.Abs(val-vl) > 4 { // very bad tolerances + if math32.Abs(val-vl) > 4 { // very bad tolerances t.Errorf("did not decode properly: val: %v != %v", val, vl) } } @@ -206,7 +206,7 @@ func TestTwoDWrap(t *testing.T) { pat.SetShape([]int{21, 21}, nil, nil) tangs := []float32{-179, -90, 0, 90, 179} for _, ang := range tangs { - v := mat32.V2(ang, .5) + v := math32.V2(ang, .5) pc.Encode(&pat, v, Set) // fmt.Printf("ang: %g\n", ang) // for i := 0; i < 21; i++ { @@ -218,7 +218,7 @@ func TestTwoDWrap(t *testing.T) { if err != nil { t.Error(err) } - if mat32.Abs(val.X-ang) > 2 && !(val.X >= 179 && ang <= -179) { // very bad tolerances + if math32.Abs(val.X-ang) > 2 && !(val.X >= 179 && ang <= -179) { // very bad tolerances t.Errorf("did not decode properly: val: %v != %v", val.X, ang) } } diff --git a/popcode/ring.go b/popcode/ring.go index 27dbc12..a1d77a8 100644 --- a/popcode/ring.go +++ b/popcode/ring.go @@ -5,7 +5,7 @@ package popcode import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) // Ring is a OneD popcode that encodes a circular value such as an angle @@ -48,10 +48,10 @@ func (pc *Ring) Encode(pat *[]float32, val float32, n int) { pc.AllocVecs(n) rng := pc.Max - pc.Min sr := pc.Sigma * rng - if mat32.Abs(pc.Max-val) < sr { // close to top + if math32.Abs(pc.Max-val) < sr { // close to top pc.EncodeImpl(&pc.LowVec, pc.Min+(val-pc.Max), n) // 0 + (340 - 360) = -20 pc.EncodeImpl(&pc.HighVec, val, n) - } else if mat32.Abs(val-pc.Min) < sr { // close to bottom + } else if math32.Abs(val-pc.Min) < sr { // close to bottom pc.EncodeImpl(&pc.LowVec, val, n) // 0 + (340 - 360) = -20 pc.EncodeImpl(&pc.HighVec, pc.Max+(val-pc.Min), n) // 360 + (20-0) = 380 } else { @@ -71,7 +71,7 @@ func (pc *Ring) EncodeImpl(pat *[]float32, val float32, n int) { *pat = make([]float32, n) } if pc.Clip { - val = mat32.Clamp(val, pc.Min, pc.Max) + val = math32.Clamp(val, pc.Min, pc.Max) } rng := pc.Max - pc.Min gnrm := 1 / (rng * pc.Sigma) @@ -82,9 +82,9 @@ func (pc *Ring) EncodeImpl(pat *[]float32, val float32, n int) { switch pc.Code { case GaussBump: dist := gnrm * (trg - val) - act = mat32.Exp(-(dist * dist)) + act = math32.Exp(-(dist * dist)) case Localist: - dist := mat32.Abs(trg - val) + dist := math32.Abs(trg - val) if dist > incr { act = 0 } else { @@ -177,7 +177,7 @@ func (pc *Ring) Decode(pat []float32) float32 { sum += act } } - sum = mat32.Max(sum, pc.MinSum) + sum = math32.Max(sum, pc.MinSum) avg /= sum return avg } diff --git a/prjn/circle.go b/prjn/circle.go index dbb5541..39ce862 100644 --- a/prjn/circle.go +++ b/prjn/circle.go @@ -5,7 +5,7 @@ package prjn import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/edge" "github.com/emer/emergent/v2/efuns" "github.com/emer/emergent/v2/evec" @@ -27,7 +27,7 @@ type Circle struct { Start evec.Vec2i // scaling to apply to receiving unit position to compute sending center as function of recv unit position - Scale mat32.Vec2 + Scale math32.Vec2 // auto-scale sending center positions as function of relative sizes of send and recv layers -- if Start is positive then assumes it is a border, subtracted from sending size AutoScale bool @@ -77,26 +77,26 @@ func (cr *Circle) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *e sc := cr.Scale if cr.AutoScale { - ssz := mat32.V2(float32(sNx), float32(sNy)) + ssz := math32.V2(float32(sNx), float32(sNy)) if cr.Start.X >= 0 && cr.Start.Y >= 0 { ssz.X -= float32(2 * cr.Start.X) ssz.Y -= float32(2 * cr.Start.Y) } - rsz := mat32.V2(float32(rNx), float32(rNy)) + rsz := math32.V2(float32(rNx), float32(rNy)) sc = ssz.Div(rsz) } for ry := 0; ry < rNy; ry++ { for rx := 0; rx < rNx; rx++ { - sctr := mat32.V2(float32(rx)*sc.X+float32(cr.Start.X), float32(ry)*sc.Y+float32(cr.Start.Y)) + sctr := math32.V2(float32(rx)*sc.X+float32(cr.Start.X), float32(ry)*sc.Y+float32(cr.Start.Y)) for sy := 0; sy < sNy; sy++ { for sx := 0; sx < sNx; sx++ { - sp := mat32.V2(float32(sx), float32(sy)) + sp := math32.V2(float32(sx), float32(sy)) if cr.Wrap { sp.X = edge.WrapMinDist(sp.X, float32(sNx), sctr.X) sp.Y = edge.WrapMinDist(sp.Y, float32(sNy), sctr.Y) } - d := int(mat32.Round(sp.DistTo(sctr))) + d := int(math32.Round(sp.DistTo(sctr))) if d <= cr.Radius { ri := etensor.Prjn2DIndex(recv, false, ry, rx) si := etensor.Prjn2DIndex(send, false, sy, sx) @@ -131,16 +131,16 @@ func (cr *Circle) GaussWts(si, ri int, send, recv *etensor.Shape) float32 { sc := cr.Scale if cr.AutoScale { - ssz := mat32.V2(float32(sNx), float32(sNy)) + ssz := math32.V2(float32(sNx), float32(sNy)) if cr.Start.X >= 0 && cr.Start.Y >= 0 { ssz.X -= float32(2 * cr.Start.X) ssz.Y -= float32(2 * cr.Start.Y) } - rsz := mat32.V2(float32(rNx), float32(rNy)) + rsz := math32.V2(float32(rNx), float32(rNy)) sc = ssz.Div(rsz) } - sctr := mat32.V2(float32(rx)*sc.X+float32(cr.Start.X), float32(ry)*sc.Y+float32(cr.Start.Y)) - sp := mat32.V2(float32(sx), float32(sy)) + sctr := math32.V2(float32(rx)*sc.X+float32(cr.Start.X), float32(ry)*sc.Y+float32(cr.Start.Y)) + sp := math32.V2(float32(sx), float32(sy)) if cr.Wrap { sp.X = edge.WrapMinDist(sp.X, float32(sNx), sctr.X) sp.Y = edge.WrapMinDist(sp.Y, float32(sNy), sctr.Y) diff --git a/prjn/poolrect.go b/prjn/poolrect.go index c7dda83..cfc3ce3 100644 --- a/prjn/poolrect.go +++ b/prjn/poolrect.go @@ -5,7 +5,7 @@ package prjn import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/edge" "github.com/emer/emergent/v2/evec" "github.com/emer/etable/v2/etensor" @@ -24,7 +24,7 @@ type PoolRect struct { Start evec.Vec2i // scaling to apply to receiving pool osition to compute corresponding position in sending layer of the lower-left corner of rectangle - Scale mat32.Vec2 + Scale math32.Vec2 // auto-set the Scale as function of the relative pool sizes of send and recv layers (e.g., if sending layer is 2x larger than receiving, Scale = 2) AutoScale bool @@ -92,8 +92,8 @@ func (cr *PoolRect) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn sc := cr.Scale if cr.AutoScale { - ssz := mat32.V2(float32(sNx), float32(sNy)) - rsz := mat32.V2(float32(rNx), float32(rNy)) + ssz := math32.V2(float32(sNx), float32(sNy)) + rsz := math32.V2(float32(rNx), float32(rNy)) sc = ssz.Div(rsz) } @@ -112,11 +112,11 @@ func (cr *PoolRect) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn ris := rpi * rNn sst := cr.Start if cr.RoundScale { - sst.X += int(mat32.Round(float32(rx-cr.RecvStart.X) * sc.X)) - sst.Y += int(mat32.Round(float32(ry-cr.RecvStart.Y) * sc.Y)) + sst.X += int(math32.Round(float32(rx-cr.RecvStart.X) * sc.X)) + sst.Y += int(math32.Round(float32(ry-cr.RecvStart.Y) * sc.Y)) } else { - sst.X += int(mat32.Floor(float32(rx-cr.RecvStart.X) * sc.X)) - sst.Y += int(mat32.Floor(float32(ry-cr.RecvStart.Y) * sc.Y)) + sst.X += int(math32.Floor(float32(rx-cr.RecvStart.X) * sc.X)) + sst.Y += int(math32.Floor(float32(ry-cr.RecvStart.Y) * sc.Y)) } for y := 0; y < cr.Size.Y; y++ { sy, clipy := edge.Edge(sst.Y+y, sNy, cr.Wrap) diff --git a/prjn/pooltile.go b/prjn/pooltile.go index 19c59ac..14a745f 100644 --- a/prjn/pooltile.go +++ b/prjn/pooltile.go @@ -8,7 +8,7 @@ import ( "fmt" "log" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/edge" "github.com/emer/emergent/v2/efuns" "github.com/emer/emergent/v2/evec" @@ -324,14 +324,14 @@ func (pt *PoolTile) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float wshp := []int{rNuY, rNuX, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "szY", "szX"}) - fsz := mat32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fsig := pt.GaussFull.Sigma * hfsz.X // full sigma + fsz := math32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fsig := pt.GaussFull.Sigma * hfsz.X // full sigma if fsig <= 0 { fsig = pt.GaussFull.Sigma } - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -344,7 +344,7 @@ func (pt *PoolTile) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float psig = pt.GaussInPool.Sigma } - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -355,7 +355,7 @@ func (pt *PoolTile) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos + rpos := math32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos rfpos := rpos.MulScalar(pt.GaussFull.CtrMove) rppos := rpos.MulScalar(pt.GaussInPool.CtrMove) sfctr := rfpos.Mul(hfsz).Add(hfsz) // sending center for full @@ -364,7 +364,7 @@ func (pt *PoolTile) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.GaussFull.On { - sf := mat32.V2(float32(sux), float32(suy)) + sf := math32.V2(float32(sux), float32(suy)) if pt.GaussFull.Wrap { sf.X = edge.WrapMinDist(sf.X, fsz.X, sfctr.X) sf.Y = edge.WrapMinDist(sf.Y, fsz.Y, sfctr.Y) @@ -373,7 +373,7 @@ func (pt *PoolTile) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float } pwt := float32(1) if pt.GaussInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) if pt.GaussInPool.Wrap { sp.X = edge.WrapMinDist(sp.X, psz.X, spctr.X) sp.Y = edge.WrapMinDist(sp.Y, psz.Y, spctr.Y) @@ -413,14 +413,14 @@ func (pt *PoolTile) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float wshp := []int{rNuY, rNuX, pt.Size.Y, pt.Size.X, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "szY", "szX", "sNuY", "sNuX"}) - fsz := mat32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fsig := pt.GaussFull.Sigma * hfsz.X // full sigma + fsz := math32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fsig := pt.GaussFull.Sigma * hfsz.X // full sigma if fsig <= 0 { fsig = pt.GaussFull.Sigma } - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -433,7 +433,7 @@ func (pt *PoolTile) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float psig = pt.GaussInPool.Sigma } - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -443,7 +443,7 @@ func (pt *PoolTile) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos + rpos := math32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos rfpos := rpos.MulScalar(pt.GaussFull.CtrMove) rppos := rpos.MulScalar(pt.GaussInPool.CtrMove) sfctr := rfpos.Mul(hfsz).Add(hfsz) // sending center for full @@ -454,7 +454,7 @@ func (pt *PoolTile) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.GaussFull.On { - sf := mat32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) + sf := math32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) if pt.GaussFull.Wrap { sf.X = edge.WrapMinDist(sf.X, fsz.X, sfctr.X) sf.Y = edge.WrapMinDist(sf.Y, fsz.Y, sfctr.Y) @@ -463,7 +463,7 @@ func (pt *PoolTile) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float } pwt := float32(1) if pt.GaussInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) if pt.GaussInPool.Wrap { sp.X = edge.WrapMinDist(sp.X, psz.X, spctr.X) sp.Y = edge.WrapMinDist(sp.Y, psz.Y, spctr.Y) @@ -534,11 +534,11 @@ func (pt *PoolTile) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Flo wshp := []int{rNuY, rNuX, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "sNuY", "sNuX"}) - fsz := mat32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fgain := pt.SigFull.Gain * hfsz.X // full gain + fsz := math32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fgain := pt.SigFull.Gain * hfsz.X // full gain - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -548,7 +548,7 @@ func (pt *PoolTile) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Flo hpsz := psz.MulScalar(0.5) // half rf pgain := pt.SigInPool.Gain * hpsz.X // pool sigma - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -558,8 +558,8 @@ func (pt *PoolTile) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Flo hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos - sgn := mat32.V2(1, 1) + rpos := math32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos + sgn := math32.V2(1, 1) rfpos := rpos.SubScalar(0.5).MulScalar(pt.SigFull.CtrMove).AddScalar(0.5) rppos := rpos.SubScalar(0.5).MulScalar(pt.SigInPool.CtrMove).AddScalar(0.5) if rpos.X >= 1 { // flip direction half-way through @@ -580,14 +580,14 @@ func (pt *PoolTile) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Flo for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.SigFull.On { - sf := mat32.V2(float32(sux), float32(suy)) + sf := math32.V2(float32(sux), float32(suy)) sigx := efuns.Logistic(sgn.X*sf.X, fgain, sfctr.X) sigy := efuns.Logistic(sgn.Y*sf.Y, fgain, sfctr.Y) fwt = sigx * sigy } pwt := float32(1) if pt.SigInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) sigx := efuns.Logistic(sgn.X*sp.X, pgain, spctr.X) sigy := efuns.Logistic(sgn.Y*sp.Y, pgain, spctr.Y) pwt = sigx * sigy @@ -625,11 +625,11 @@ func (pt *PoolTile) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Flo wshp := []int{rNuY, rNuX, pt.Size.Y, pt.Size.X, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "szY", "szX", "sNuY", "sNuX"}) - fsz := mat32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fgain := pt.SigFull.Gain * hfsz.X // full gain + fsz := math32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fgain := pt.SigFull.Gain * hfsz.X // full gain - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -639,7 +639,7 @@ func (pt *PoolTile) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Flo hpsz := psz.MulScalar(0.5) // half rf pgain := pt.SigInPool.Gain * hpsz.X // pool sigma - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -649,8 +649,8 @@ func (pt *PoolTile) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Flo hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos - sgn := mat32.V2(1, 1) + rpos := math32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos + sgn := math32.V2(1, 1) rfpos := rpos.SubScalar(0.5).MulScalar(pt.SigFull.CtrMove).AddScalar(0.5) rppos := rpos.SubScalar(0.5).MulScalar(pt.SigInPool.CtrMove).AddScalar(0.5) if rpos.X >= 1 { // flip direction half-way through @@ -673,14 +673,14 @@ func (pt *PoolTile) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Flo for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.SigFull.On { - sf := mat32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) + sf := math32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) sigx := efuns.Logistic(sgn.X*sf.X, fgain, sfctr.X) sigy := efuns.Logistic(sgn.Y*sf.Y, fgain, sfctr.Y) fwt = sigx * sigy } pwt := float32(1) if pt.SigInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) sigx := efuns.Logistic(sgn.X*sp.X, pgain, spctr.X) sigy := efuns.Logistic(sgn.Y*sp.Y, pgain, spctr.Y) pwt = sigx * sigy diff --git a/prjn/pooltilesub.go b/prjn/pooltilesub.go index 01b92b8..0eb32da 100644 --- a/prjn/pooltilesub.go +++ b/prjn/pooltilesub.go @@ -8,7 +8,7 @@ import ( "fmt" "log" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/edge" "github.com/emer/emergent/v2/efuns" "github.com/emer/emergent/v2/evec" @@ -307,14 +307,14 @@ func (pt *PoolTileSub) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Fl wshp := []int{rNuY, rNuX, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "szY", "szX"}) - fsz := mat32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fsig := pt.GaussFull.Sigma * hfsz.X // full sigma + fsz := math32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fsig := pt.GaussFull.Sigma * hfsz.X // full sigma if fsig <= 0 { fsig = pt.GaussFull.Sigma } - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -327,7 +327,7 @@ func (pt *PoolTileSub) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Fl psig = pt.GaussInPool.Sigma } - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -338,7 +338,7 @@ func (pt *PoolTileSub) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Fl hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos + rpos := math32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos rfpos := rpos.MulScalar(pt.GaussFull.CtrMove) rppos := rpos.MulScalar(pt.GaussInPool.CtrMove) sfctr := rfpos.Mul(hfsz).Add(hfsz) // sending center for full @@ -347,7 +347,7 @@ func (pt *PoolTileSub) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Fl for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.GaussFull.On { - sf := mat32.V2(float32(sux), float32(suy)) + sf := math32.V2(float32(sux), float32(suy)) if pt.GaussFull.Wrap { sf.X = edge.WrapMinDist(sf.X, fsz.X, sfctr.X) sf.Y = edge.WrapMinDist(sf.Y, fsz.Y, sfctr.Y) @@ -356,7 +356,7 @@ func (pt *PoolTileSub) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Fl } pwt := float32(1) if pt.GaussInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) if pt.GaussInPool.Wrap { sp.X = edge.WrapMinDist(sp.X, psz.X, spctr.X) sp.Y = edge.WrapMinDist(sp.Y, psz.Y, spctr.Y) @@ -396,14 +396,14 @@ func (pt *PoolTileSub) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Fl wshp := []int{rNuY, rNuX, pt.Size.Y, pt.Size.X, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "szY", "szX", "sNuY", "sNuX"}) - fsz := mat32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fsig := pt.GaussFull.Sigma * hfsz.X // full sigma + fsz := math32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fsig := pt.GaussFull.Sigma * hfsz.X // full sigma if fsig <= 0 { fsig = pt.GaussFull.Sigma } - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -416,7 +416,7 @@ func (pt *PoolTileSub) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Fl psig = pt.GaussInPool.Sigma } - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -426,7 +426,7 @@ func (pt *PoolTileSub) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Fl hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos + rpos := math32.V2(float32(rux), float32(ruy)).Sub(hrsz).Div(hrsz) // -1..1 normalized r unit pos rfpos := rpos.MulScalar(pt.GaussFull.CtrMove) rppos := rpos.MulScalar(pt.GaussInPool.CtrMove) sfctr := rfpos.Mul(hfsz).Add(hfsz) // sending center for full @@ -437,7 +437,7 @@ func (pt *PoolTileSub) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Fl for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.GaussFull.On { - sf := mat32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) + sf := math32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) if pt.GaussFull.Wrap { sf.X = edge.WrapMinDist(sf.X, fsz.X, sfctr.X) sf.Y = edge.WrapMinDist(sf.Y, fsz.Y, sfctr.Y) @@ -446,7 +446,7 @@ func (pt *PoolTileSub) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Fl } pwt := float32(1) if pt.GaussInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) if pt.GaussInPool.Wrap { sp.X = edge.WrapMinDist(sp.X, psz.X, spctr.X) sp.Y = edge.WrapMinDist(sp.Y, psz.Y, spctr.Y) @@ -490,11 +490,11 @@ func (pt *PoolTileSub) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor. wshp := []int{rNuY, rNuX, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "sNuY", "sNuX"}) - fsz := mat32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fgain := pt.SigFull.Gain * hfsz.X // full gain + fsz := math32.V2(float32(sNuX-1), float32(sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fgain := pt.SigFull.Gain * hfsz.X // full gain - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -504,7 +504,7 @@ func (pt *PoolTileSub) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor. hpsz := psz.MulScalar(0.5) // half rf pgain := pt.SigInPool.Gain * hpsz.X // pool sigma - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -514,8 +514,8 @@ func (pt *PoolTileSub) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor. hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos - sgn := mat32.V2(1, 1) + rpos := math32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos + sgn := math32.V2(1, 1) rfpos := rpos.SubScalar(0.5).MulScalar(pt.SigFull.CtrMove).AddScalar(0.5) rppos := rpos.SubScalar(0.5).MulScalar(pt.SigInPool.CtrMove).AddScalar(0.5) if rpos.X >= 1 { // flip direction half-way through @@ -536,14 +536,14 @@ func (pt *PoolTileSub) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor. for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.SigFull.On { - sf := mat32.V2(float32(sux), float32(suy)) + sf := math32.V2(float32(sux), float32(suy)) sigx := efuns.Logistic(sgn.X*sf.X, fgain, sfctr.X) sigy := efuns.Logistic(sgn.Y*sf.Y, fgain, sfctr.Y) fwt = sigx * sigy } pwt := float32(1) if pt.SigInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) sigx := efuns.Logistic(sgn.X*sp.X, pgain, spctr.X) sigy := efuns.Logistic(sgn.Y*sp.Y, pgain, spctr.Y) pwt = sigx * sigy @@ -581,11 +581,11 @@ func (pt *PoolTileSub) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor. wshp := []int{rNuY, rNuX, pt.Size.Y, pt.Size.X, sNuY, sNuX} wts.SetShape(wshp, nil, []string{"rNuY", "rNuX", "szY", "szX", "sNuY", "sNuX"}) - fsz := mat32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size - hfsz := fsz.MulScalar(0.5) // half rf - fgain := pt.SigFull.Gain * hfsz.X // full gain + fsz := math32.V2(float32(pt.Size.X*sNuX-1), float32(pt.Size.Y*sNuY-1)) // full rf size + hfsz := fsz.MulScalar(0.5) // half rf + fgain := pt.SigFull.Gain * hfsz.X // full gain - psz := mat32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size + psz := math32.V2(float32(sNuX), float32(sNuY)) // within-pool rf size if sNuX > 1 { psz.X -= 1 } @@ -595,7 +595,7 @@ func (pt *PoolTileSub) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor. hpsz := psz.MulScalar(0.5) // half rf pgain := pt.SigInPool.Gain * hpsz.X // pool sigma - rsz := mat32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size + rsz := math32.V2(float32(rNuX), float32(rNuY)) // recv units-in-pool size if rNuX > 1 { rsz.X -= 1 } @@ -605,8 +605,8 @@ func (pt *PoolTileSub) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor. hrsz := rsz.MulScalar(0.5) for ruy := 0; ruy < rNuY; ruy++ { for rux := 0; rux < rNuX; rux++ { - rpos := mat32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos - sgn := mat32.V2(1, 1) + rpos := math32.V2(float32(rux), float32(ruy)).Div(hrsz) // 0..2 normalized r unit pos + sgn := math32.V2(1, 1) rfpos := rpos.SubScalar(0.5).MulScalar(pt.SigFull.CtrMove).AddScalar(0.5) rppos := rpos.SubScalar(0.5).MulScalar(pt.SigInPool.CtrMove).AddScalar(0.5) if rpos.X >= 1 { // flip direction half-way through @@ -629,14 +629,14 @@ func (pt *PoolTileSub) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor. for sux := 0; sux < sNuX; sux++ { fwt := float32(1) if pt.SigFull.On { - sf := mat32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) + sf := math32.V2(float32(fx*sNuX+sux), float32(fy*sNuY+suy)) sigx := efuns.Logistic(sgn.X*sf.X, fgain, sfctr.X) sigy := efuns.Logistic(sgn.Y*sf.Y, fgain, sfctr.Y) fwt = sigx * sigy } pwt := float32(1) if pt.SigInPool.On { - sp := mat32.V2(float32(sux), float32(suy)) + sp := math32.V2(float32(sux), float32(suy)) sigx := efuns.Logistic(sgn.X*sp.X, pgain, spctr.X) sigy := efuns.Logistic(sgn.Y*sp.Y, pgain, spctr.Y) pwt = sigx * sigy diff --git a/prjn/poolunifrnd.go b/prjn/poolunifrnd.go index 614f465..bff2e3b 100644 --- a/prjn/poolunifrnd.go +++ b/prjn/poolunifrnd.go @@ -153,7 +153,7 @@ func (ur *PoolUnifRnd) ConnectRnd(send, recv *etensor.Shape, same bool) (sendn, // recv number is even distribution across recvs plus some imbalance factor // nrMean := float32(rlen*nsend) / float32(slen) // // add 3 * SEM as corrective factor - // nrSEM := nrMean / mat32.Sqrt(nrMean) + // nrSEM := nrMean / math32.Sqrt(nrMean) // nrecv := int(nrMean + 3*nrSEM) // if nrecv > rlen { // nrecv = rlen diff --git a/prjn/rect.go b/prjn/rect.go index f919000..be8d84d 100644 --- a/prjn/rect.go +++ b/prjn/rect.go @@ -5,7 +5,7 @@ package prjn import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/emergent/v2/edge" "github.com/emer/emergent/v2/evec" "github.com/emer/etable/v2/etensor" @@ -24,7 +24,7 @@ type Rect struct { Start evec.Vec2i // scaling to apply to receiving unit position to compute corresponding position in sending layer of the lower-left corner of rectangle - Scale mat32.Vec2 + Scale math32.Vec2 // auto-set the Scale as function of the relative sizes of send and recv layers (e.g., if sending layer is 2x larger than receiving, Scale = 2) AutoScale bool @@ -102,8 +102,8 @@ func (cr *Rect) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *ete sc := cr.Scale if cr.AutoScale { - ssz := mat32.V2(float32(sNx), float32(sNy)) - rsz := mat32.V2(float32(rNxEff), float32(rNyEff)) + ssz := math32.V2(float32(sNx), float32(sNy)) + rsz := math32.V2(float32(rNxEff), float32(rNyEff)) sc = ssz.Div(rsz) } @@ -112,11 +112,11 @@ func (cr *Rect) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *ete ri := etensor.Prjn2DIndex(recv, false, ry, rx) sst := cr.Start if cr.RoundScale { - sst.X += int(mat32.Round(float32(rx-cr.RecvStart.X) * sc.X)) - sst.Y += int(mat32.Round(float32(ry-cr.RecvStart.Y) * sc.Y)) + sst.X += int(math32.Round(float32(rx-cr.RecvStart.X) * sc.X)) + sst.Y += int(math32.Round(float32(ry-cr.RecvStart.Y) * sc.Y)) } else { - sst.X += int(mat32.Floor(float32(rx-cr.RecvStart.X) * sc.X)) - sst.Y += int(mat32.Floor(float32(ry-cr.RecvStart.Y) * sc.Y)) + sst.X += int(math32.Floor(float32(rx-cr.RecvStart.X) * sc.X)) + sst.Y += int(math32.Floor(float32(ry-cr.RecvStart.Y) * sc.Y)) } for y := 0; y < cr.Size.Y; y++ { sy, clipy := edge.Edge(sst.Y+y, sNy, cr.Wrap) @@ -170,8 +170,8 @@ func (cr *Rect) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn sc := cr.Scale if cr.AutoScale { - ssz := mat32.V2(float32(sNx), float32(sNy)) - rsz := mat32.V2(float32(rNxEff), float32(rNyEff)) + ssz := math32.V2(float32(sNx), float32(sNy)) + rsz := math32.V2(float32(rNxEff), float32(rNyEff)) sc = ssz.Div(rsz) } @@ -180,11 +180,11 @@ func (cr *Rect) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn ri := etensor.Prjn2DIndex(send, false, ry, rx) sst := cr.Start if cr.RoundScale { - sst.X += int(mat32.Round(float32(rx-cr.RecvStart.X) * sc.X)) - sst.Y += int(mat32.Round(float32(ry-cr.RecvStart.Y) * sc.Y)) + sst.X += int(math32.Round(float32(rx-cr.RecvStart.X) * sc.X)) + sst.Y += int(math32.Round(float32(ry-cr.RecvStart.Y) * sc.Y)) } else { - sst.X += int(mat32.Floor(float32(rx-cr.RecvStart.X) * sc.X)) - sst.Y += int(mat32.Floor(float32(ry-cr.RecvStart.Y) * sc.Y)) + sst.X += int(math32.Floor(float32(rx-cr.RecvStart.X) * sc.X)) + sst.Y += int(math32.Floor(float32(ry-cr.RecvStart.Y) * sc.Y)) } for y := 0; y < cr.Size.Y; y++ { sy, clipy := edge.Edge(sst.Y+y, sNy, cr.Wrap) diff --git a/prjn/unifrnd.go b/prjn/unifrnd.go index 7c2a450..7c34f37 100644 --- a/prjn/unifrnd.go +++ b/prjn/unifrnd.go @@ -79,7 +79,7 @@ func (ur *UnifRnd) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn * // recv number is even distribution across recvs plus some imbalance factor // nrMean := float32(rlen*nsend) / float32(slen) // // add 3 * SEM as corrective factor - // nrSEM := nrMean / mat32.Sqrt(nrMean) + // nrSEM := nrMean / math32.Sqrt(nrMean) // nrecv := int(nrMean + 3*nrSEM) // if nrecv > rlen { // nrecv = rlen diff --git a/relpos/rel.go b/relpos/rel.go index 7d8a9cf..8a11cac 100644 --- a/relpos/rel.go +++ b/relpos/rel.go @@ -13,7 +13,7 @@ package relpos //go:generate core generate -add-types import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) // Rel defines a position relationship among layers, in terms of X,Y width and height of layer @@ -85,7 +85,7 @@ func NewAbove(other string) Rel { // Pos returns the relative position compared to other position and size, based on settings // osz and sz must both have already been scaled by relevant Scale factor -func (rp *Rel) Pos(op mat32.Vec3, osz mat32.Vec2, sz mat32.Vec2) mat32.Vec3 { +func (rp *Rel) Pos(op math32.Vec3, osz math32.Vec2, sz math32.Vec2) math32.Vec3 { if rp.Scale == 0 { rp.Defaults() } diff --git a/relpos/rel_test.go b/relpos/rel_test.go index bdd2034..b970459 100644 --- a/relpos/rel_test.go +++ b/relpos/rel_test.go @@ -8,7 +8,7 @@ import ( "fmt" "testing" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) func TestRels(t *testing.T) { @@ -16,12 +16,12 @@ func TestRels(t *testing.T) { rp.Defaults() rp.Rel = RightOf rp.YAlign = Center - rs := rp.Pos(mat32.Vec3{}, mat32.V2(10, 10), mat32.V2(4, 4)) + rs := rp.Pos(math32.Vec3{}, math32.V2(10, 10), math32.V2(4, 4)) fmt.Printf("rp: %v rs: %v\n", rp, rs) rp.YAlign = Front - rs = rp.Pos(mat32.Vec3{}, mat32.V2(10, 10), mat32.V2(4, 4)) + rs = rp.Pos(math32.Vec3{}, math32.V2(10, 10), math32.V2(4, 4)) fmt.Printf("rp: %v rs: %v\n", rp, rs) rp.YAlign = Back - rs = rp.Pos(mat32.Vec3{}, mat32.V2(10, 10), mat32.V2(4, 4)) + rs = rp.Pos(math32.Vec3{}, math32.V2(10, 10), math32.V2(4, 4)) fmt.Printf("rp: %v rs: %v\n", rp, rs) }