diff --git a/README.md b/README.md index 415f3a4..1373458 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ The flags are: Note: any existing `.go` files in the output directory will be removed prior to processing, because the entire directory is built to establish all the types, which might be distributed across multiple files. Any existing `.hlsl` files with the same filenames as those extracted from the `.go` files will be overwritten. Otherwise, you can maintain other custom `.hlsl` files in the `shaders` directory, although it is recommended to treat the entire directory as automatically generated, to avoid any issues. -`gosl` path args can include filenames, directory names, or Go package paths (e.g., `cogentcore.org/core/mat32/fastexp.go` loads just that file from the given package) -- files without any `//gosl:` comment directives will be skipped up front before any expensive processing, so it is not a problem to specify entire directories where only some files are relevant. Also, you can specify a particular file from a directory, then the entire directory, to ensure that a particular file from that directory appears first -- otherwise alphabetical order is used. `gosl` ensures that only one copy of each file is included. +`gosl` path args can include filenames, directory names, or Go package paths (e.g., `cogentcore.org/core/math32/fastexp.go` loads just that file from the given package) -- files without any `//gosl:` comment directives will be skipped up front before any expensive processing, so it is not a problem to specify entire directories where only some files are relevant. Also, you can specify a particular file from a directory, then the entire directory, to ensure that a particular file from that directory appears first -- otherwise alphabetical order is used. `gosl` ensures that only one copy of each file is included. Any `struct` types encountered will be checked for 16-byte alignment of sub-types and overall sizes as an even multiple of 16 bytes (4 `float32` or `int32` values), which is the alignment used in HLSL and glsl shader languages, and the underlying GPU hardware presumably. Look for error messages on the output from the gosl run. This ensures that direct byte-wise copies of data between CPU and GPU will be successful. The fact that `gosl` operates directly on the original CPU-side Go code uniquely enables it to perform these alignment checks, which are otherwise a major source of difficult-to-diagnose bugs. diff --git a/examples/axon/Makefile b/examples/axon/Makefile index 95ca7d6..3f4c336 100644 --- a/examples/axon/Makefile +++ b/examples/axon/Makefile @@ -1,3 +1,3 @@ all: - ../../gosl -keep -exclude=Update,UpdateParams,Defaults cogentcore.org/core/mat32/fastexp.go minmax chans/chans.go chans kinase time.go neuron.go act.go learn.go layer.go axon.hlsl + ../../gosl -keep -exclude=Update,UpdateParams,Defaults cogentcore.org/core/math32/fastexp.go minmax chans/chans.go chans kinase time.go neuron.go act.go learn.go layer.go axon.hlsl diff --git a/examples/axon/act.go b/examples/axon/act.go index 712634e..494e3b4 100644 --- a/examples/axon/act.go +++ b/examples/axon/act.go @@ -5,7 +5,7 @@ package main import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/gosl/v2/examples/axon/chans" "github.com/emer/gosl/v2/examples/axon/minmax" "github.com/emer/gosl/v2/slbool" @@ -365,8 +365,8 @@ type SpikeNoiseParams struct { } func (an *SpikeNoiseParams) Update() { - an.GeExpInt = mat32.Exp(-1000.0 / an.GeHz) - an.GiExpInt = mat32.Exp(-1000.0 / an.GiHz) + an.GeExpInt = math32.Exp(-1000.0 / an.GeHz) + an.GiExpInt = math32.Exp(-1000.0 / an.GiHz) } func (an *SpikeNoiseParams) Defaults() { @@ -878,7 +878,7 @@ func (ac *ActParams) VmFromG(nrn *Neuron) { if updtVm && slbool.IsTrue(ac.Spike.Exp) { // add spike current if relevant exVm = 0.5 * (nvm + nrn.Vm) // midpoint for this expi = ac.Gbar.L * ac.Spike.ExpSlope * - mat32.FastExp((exVm-ac.Spike.Thr)/ac.Spike.ExpSlope) + math32.FastExp((exVm-ac.Spike.Thr)/ac.Spike.ExpSlope) if expi > ac.Dt.VmTau { expi = ac.Dt.VmTau } diff --git a/examples/axon/chans/ak.go b/examples/axon/chans/ak.go index 653b279..0c9fd07 100644 --- a/examples/axon/chans/ak.go +++ b/examples/axon/chans/ak.go @@ -4,7 +4,7 @@ package chans -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" // AKParams control an A-type K channel, which is voltage gated with maximal // activation around -37 mV. It has two state variables, M (v-gated opening) @@ -67,22 +67,22 @@ func (ap *AKParams) Proximal() { // AlphaFromVK returns the Alpha function from vbio (not normalized, must not exceed 0) func (ap *AKParams) AlphaFromVK(vbio, k float32) float32 { - return mat32.FastExp(0.03707 * k * (vbio - ap.Voff)) + return math32.FastExp(0.03707 * k * (vbio - ap.Voff)) } // BetaFromVK returns the Beta function from vbio (not normalized, must not exceed 0) func (ap *AKParams) BetaFromVK(vbio, k float32) float32 { - return mat32.FastExp(ap.Beta * k * (vbio - ap.Voff)) + return math32.FastExp(ap.Beta * k * (vbio - ap.Voff)) } // KFromV returns the K value from vbio (not normalized, must not exceed 0) func (ap *AKParams) KFromV(vbio float32) float32 { - return -ap.Koff - 1.0/(1.0+mat32.FastExp((vbio+40)/5)) + return -ap.Koff - 1.0/(1.0+math32.FastExp((vbio+40)/5)) } // HFromV returns the H gate value from vbio (not normalized, must not exceed 0) func (ap *AKParams) HFromV(vbio float32) float32 { - return 1.0 / (1.0 + mat32.FastExp(ap.Hf*(vbio+56))) + return 1.0 / (1.0 + math32.FastExp(ap.Hf*(vbio+56))) } // HTauFromV returns the HTau rate constant in msec from vbio (not normalized, must not exceed 0) @@ -172,7 +172,7 @@ func (ap *AKsParams) MFromV(vbio float32) float32 { if vbio > ap.Vmax { vbio = ap.Vmax } - return ap.Hf / (1.0 + mat32.FastExp(-ap.Mf*(vbio+ap.Voff))) + return ap.Hf / (1.0 + math32.FastExp(-ap.Mf*(vbio+ap.Voff))) } // MFromVnorm returns the M gate function from vnorm diff --git a/examples/axon/chans/gabab.go b/examples/axon/chans/gabab.go index 97ad68e..de59cd2 100644 --- a/examples/axon/chans/gabab.go +++ b/examples/axon/chans/gabab.go @@ -5,7 +5,7 @@ package chans import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) //gosl: start axon @@ -48,8 +48,8 @@ func (gp *GABABParams) Defaults() { } func (gp *GABABParams) Update() { - gp.TauFact = mat32.Pow(gp.DecayTau/gp.RiseTau, gp.RiseTau/(gp.DecayTau-gp.RiseTau)) - gp.MaxTime = ((gp.RiseTau * gp.DecayTau) / (gp.DecayTau - gp.RiseTau)) * mat32.Log(gp.DecayTau/gp.RiseTau) + gp.TauFact = math32.Pow(gp.DecayTau/gp.RiseTau, gp.RiseTau/(gp.DecayTau-gp.RiseTau)) + gp.MaxTime = ((gp.RiseTau * gp.DecayTau) / (gp.DecayTau - gp.RiseTau)) * math32.Log(gp.DecayTau/gp.RiseTau) } // GFromV returns the GABA-B conductance as a function of normalized membrane potential @@ -59,7 +59,7 @@ func (gp *GABABParams) GFromV(v float32) float32 { if vbio < -90 { vbio = -90 } - return 1.0 / (1.0 + mat32.FastExp(0.1*((vbio+90)+10))) + return 1.0 / (1.0 + math32.FastExp(0.1*((vbio+90)+10))) } // GFromS returns the GABA-B conductance as a function of GABA spiking rate, @@ -70,7 +70,7 @@ func (gp *GABABParams) GFromS(s float32) float32 { if ss > 10 { ss = 10 } - return 1.0 / (1.0 + mat32.FastExp(-(ss-7.1)/1.4)) + return 1.0 / (1.0 + math32.FastExp(-(ss-7.1)/1.4)) } // DG returns dG delta for g diff --git a/examples/axon/chans/mahp.go b/examples/axon/chans/mahp.go index 2f7c511..de8f227 100644 --- a/examples/axon/chans/mahp.go +++ b/examples/axon/chans/mahp.go @@ -4,7 +4,7 @@ package chans -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" //gosl: start axon @@ -43,7 +43,7 @@ func (mp *MahpParams) Defaults() { mp.Voff = -30 mp.Vslope = 9 mp.TauMax = 1000 - mp.Tadj = mat32.Pow(2.3, (37.0-23.0)/10.0) // 3.2 basically + mp.Tadj = math32.Pow(2.3, (37.0-23.0)/10.0) // 3.2 basically mp.Update() } @@ -53,10 +53,10 @@ func (mp *MahpParams) Update() { // EFun handles singularities in an elegant way -- from Mainen impl func (mp *MahpParams) EFun(z float32) float32 { - if mat32.Abs(z) < 1.0e-4 { + if math32.Abs(z) < 1.0e-4 { return 1.0 - 0.5*z } - return z / (mat32.FastExp(z) - 1.0) + return z / (math32.FastExp(z) - 1.0) } // NinfTauFromV returns the target infinite-time N gate value and @@ -66,8 +66,8 @@ func (mp *MahpParams) NinfTauFromV(vbio float32, ninf, tau *float32) { vo = vbio - mp.Voff // logical functions, but have signularity at Voff (vo = 0) - // a := mp.DtMax * vo / (1.0 - mat32.FastExp(-vo/mp.Vslope)) - // b := -mp.DtMax * vo / (1.0 - mat32.FastExp(vo/mp.Vslope)) + // a := mp.DtMax * vo / (1.0 - math32.FastExp(-vo/mp.Vslope)) + // b := -mp.DtMax * vo / (1.0 - math32.FastExp(vo/mp.Vslope)) a = mp.DtMax * mp.Vslope * mp.EFun(-vo/mp.Vslope) b = mp.DtMax * mp.Vslope * mp.EFun(vo/mp.Vslope) @@ -86,7 +86,7 @@ func (mp *MahpParams) NinfTauFromVnorm(v float32, ninf, tau *float32) { func (mp *MahpParams) DNFromV(v, n float32) float32 { var ninf, tau float32 mp.NinfTauFromVnorm(v, &ninf, &tau) - // dt := 1.0 - mat32.FastExp(-mp.Tadj/tau) // Mainen comments out this form; Poirazi uses + // dt := 1.0 - math32.FastExp(-mp.Tadj/tau) // Mainen comments out this form; Poirazi uses // dt := mp.Tadj / tau // simple linear fix return (ninf - n) / tau } diff --git a/examples/axon/chans/nmda.go b/examples/axon/chans/nmda.go index 419dd46..8f53d6a 100644 --- a/examples/axon/chans/nmda.go +++ b/examples/axon/chans/nmda.go @@ -4,7 +4,7 @@ package chans -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" //gosl: start axon @@ -62,7 +62,7 @@ func (np *NMDAParams) MgGFromVbio(vbio float32) float32 { if vbio >= 0 { return 0 } - return 1.0 / (1.0 + np.MgFact*mat32.FastExp(-0.062*vbio)) + return 1.0 / (1.0 + np.MgFact*math32.FastExp(-0.062*vbio)) } // MgGFromV returns the NMDA conductance as a function of normalized membrane potential @@ -79,7 +79,7 @@ func (np *NMDAParams) CaFromVbio(vbio float32) float32 { if vbio > -0.1 && vbio < 0.1 { return 1.0 / (0.0756 + 0.5*vbio) } - return -vbio / (1.0 - mat32.FastExp(0.0756*vbio)) + return -vbio / (1.0 - math32.FastExp(0.0756*vbio)) } // CaFromV returns the calcium current factor as a function of normalized membrane diff --git a/examples/axon/chans/sahp.go b/examples/axon/chans/sahp.go index 7e0994b..26fb3f9 100644 --- a/examples/axon/chans/sahp.go +++ b/examples/axon/chans/sahp.go @@ -4,7 +4,7 @@ package chans -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" //gosl: start axon @@ -58,10 +58,10 @@ func (mp *SahpParams) Update() { // EFun handles singularities in an elegant way -- from Mainen impl func (mp *SahpParams) EFun(z float32) float32 { - if mat32.Abs(z) < 1.0e-4 { + if math32.Abs(z) < 1.0e-4 { return 1.0 - 0.5*z } - return z / (mat32.FastExp(z) - 1.0) + return z / (math32.FastExp(z) - 1.0) } // NinfTauFromCa returns the target infinite-time N gate value and @@ -71,8 +71,8 @@ func (mp *SahpParams) NinfTauFromCa(ca float32, ninf, tau *float32) { co = ca - mp.Off // logical functions, but have signularity at Voff (vo = 0) - // a := mp.DtMax * vo / (1.0 - mat32.FastExp(-vo/mp.Vslope)) - // b := -mp.DtMax * vo / (1.0 - mat32.FastExp(vo/mp.Vslope)) + // a := mp.DtMax * vo / (1.0 - math32.FastExp(-vo/mp.Vslope)) + // b := -mp.DtMax * vo / (1.0 - math32.FastExp(vo/mp.Vslope)) a = mp.DtMax * mp.Slope * mp.EFun(-co/mp.Slope) b = mp.DtMax * mp.Slope * mp.EFun(co/mp.Slope) diff --git a/examples/axon/chans/vgcc.go b/examples/axon/chans/vgcc.go index 6ec2afb..d5b5752 100644 --- a/examples/axon/chans/vgcc.go +++ b/examples/axon/chans/vgcc.go @@ -5,7 +5,7 @@ package chans import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) //gosl: start axon @@ -37,7 +37,7 @@ func (np *VGCCParams) GFromV(v float32) float32 { if vbio > -0.1 && vbio < 0.1 { return 1.0 / (0.0756 + 0.5*vbio) } - return -vbio / (1.0 - mat32.FastExp(0.0756*vbio)) + return -vbio / (1.0 - math32.FastExp(0.0756*vbio)) } // MFromV returns the M gate function from vbio (not normalized, must not exceed 0) @@ -48,7 +48,7 @@ func (np *VGCCParams) MFromV(vbio float32) float32 { if vbio > -10 { return 1 } - return 1.0 / (1.0 + mat32.FastExp(-(vbio + 37))) + return 1.0 / (1.0 + math32.FastExp(-(vbio + 37))) } // HFromV returns the H gate function from vbio (not normalized, must not exceed 0) @@ -59,7 +59,7 @@ func (np *VGCCParams) HFromV(vbio float32) float32 { if vbio > -10 { return 0 } - return 1.0 / (1.0 + mat32.FastExp((vbio+41)*2)) + return 1.0 / (1.0 + math32.FastExp((vbio+41)*2)) } // DMHFromV returns the change at msec update scale in M, H factors diff --git a/examples/axon/learn.go b/examples/axon/learn.go index cf25712..7bb38f6 100644 --- a/examples/axon/learn.go +++ b/examples/axon/learn.go @@ -5,7 +5,7 @@ package main import ( - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/gosl/v2/examples/axon/chans" "github.com/emer/gosl/v2/examples/axon/kinase" "github.com/emer/gosl/v2/examples/axon/minmax" @@ -119,7 +119,7 @@ func (np *CaSpkParams) Defaults() { func (np *CaSpkParams) Update() { np.Dt.Update() np.SynDt = 1 / np.SynTau - np.SynSpkG = mat32.Sqrt(30) / mat32.Sqrt(np.SynTau) + np.SynSpkG = math32.Sqrt(30) / math32.Sqrt(np.SynTau) } // CaFromSpike computes CaSpk* and CaSyn calcium signals based on current spike. @@ -243,9 +243,9 @@ func (rl *RLRateParams) RLRateDiff(scap, scad float32) float32 { if slbool.IsFalse(rl.On) || slbool.IsFalse(rl.Diff) { return 1.0 } - mx := mat32.Max(scap, scad) + mx := math32.Max(scap, scad) if mx > rl.SpkThr { // avoid div by 0 - dif := mat32.Abs(scap - scad) + dif := math32.Abs(scap - scad) if dif < rl.DiffThr { return rl.Min } diff --git a/examples/axon/main.go b/examples/axon/main.go index 115a86c..f03f64e 100644 --- a/examples/axon/main.go +++ b/examples/axon/main.go @@ -11,7 +11,7 @@ import ( "log/slog" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "cogentcore.org/core/vgpu" "github.com/emer/emergent/v2/timer" "github.com/emer/gosl/v2/sltype" @@ -23,7 +23,7 @@ const DiffTol = 1.0e-3 // note: standard one to use is plain "gosl" which should be go install'd -//go:generate ../../gosl -exclude=Update,UpdateParams,Defaults -keep cogentcore.org/core/mat32/fastexp.go minmax chans/chans.go chans kinase time.go neuron.go act.go learn.go layer.go axon.hlsl +//go:generate ../../gosl -exclude=Update,UpdateParams,Defaults -keep cogentcore.org/core/math32/fastexp.go minmax chans/chans.go chans kinase time.go neuron.go act.go learn.go layer.go axon.hlsl func init() { // must lock main thread for gpu! this also means that vulkan must be used @@ -49,7 +49,7 @@ func main() { // AMD is 64, NVIDIA, M1 are 32 gpuThreads := 64 cpuThreads := 10 - nInt := int(mat32.IntMultiple(float32(n), float32(gpuThreads))) + nInt := int(math32.IntMultiple(float32(n), float32(gpuThreads))) n = nInt // enforce optimal n's -- otherwise requires range checking nGps := nInt / gpuThreads // dispatch n @@ -201,7 +201,7 @@ func main() { v1 := d1.VarByIndex(vi) v2 := d2.VarByIndex(vi) diff := "" - if mat32.Abs(v1-v2) > DiffTol { + if math32.Abs(v1-v2) > DiffTol { diff = "*" anyDiff = true } diff --git a/examples/axon/neuron.go b/examples/axon/neuron.go index 8357f7b..7de91c1 100644 --- a/examples/axon/neuron.go +++ b/examples/axon/neuron.go @@ -9,7 +9,7 @@ import ( "reflect" "unsafe" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" ) //gosl: start axon @@ -373,7 +373,7 @@ func (nrn *Neuron) VarByIndex(idx int) float32 { func (nrn *Neuron) VarByName(varNm string) (float32, error) { i, err := NeuronVarIndexByName(varNm) if err != nil { - return mat32.NaN(), err + return math32.NaN(), err } return nrn.VarByIndex(i), nil } diff --git a/examples/basic/compute.go b/examples/basic/compute.go index 982b3c8..3b5b7ec 100644 --- a/examples/basic/compute.go +++ b/examples/basic/compute.go @@ -4,7 +4,7 @@ package main -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" //gosl: hlsl basic // #include "fastexp.hlsl" @@ -43,7 +43,7 @@ type ParamStruct struct { // IntegFromRaw computes integrated value from current raw value func (ps *ParamStruct) IntegFromRaw(ds *DataStruct) { ds.Integ += ps.Dt * (ds.Raw - ds.Integ) - ds.Exp = mat32.FastExp(-ds.Integ) + ds.Exp = math32.FastExp(-ds.Integ) } //gosl: end basic diff --git a/examples/basic/main.go b/examples/basic/main.go index a0c9690..09cec70 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -10,14 +10,14 @@ import ( "runtime" "unsafe" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "cogentcore.org/core/vgpu" "github.com/emer/emergent/v2/timer" ) // note: standard one to use is plain "gosl" which should be go install'd -//go:generate ../../gosl cogentcore.org/core/mat32/fastexp.go compute.go +//go:generate ../../gosl cogentcore.org/core/math32/fastexp.go compute.go func init() { // must lock main thread for gpu! this also means that vulkan must be used @@ -38,7 +38,7 @@ func main() { n := 100000000 // get 80x with 100m, 50x with 10m threads := 64 - nInt := int(mat32.IntMultiple(float32(n), float32(threads))) + nInt := int(math32.IntMultiple(float32(n), float32(threads))) n = nInt // enforce optimal n's -- otherwise requires range checking nGps := nInt / threads // dispatch n diff --git a/examples/rand/main.go b/examples/rand/main.go index b976bee..9f4a089 100644 --- a/examples/rand/main.go +++ b/examples/rand/main.go @@ -11,7 +11,7 @@ import ( "log/slog" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "cogentcore.org/core/vgpu" "github.com/emer/emergent/v2/timer" "github.com/emer/gosl/v2/sltype" @@ -41,7 +41,7 @@ func main() { // n := 10 n := 10000000 threads := 64 - nInt := int(mat32.IntMultiple(float32(n), float32(threads))) + nInt := int(math32.IntMultiple(float32(n), float32(threads))) n = nInt // enforce optimal n's -- otherwise requires range checking nGps := nInt / threads // dispatch n diff --git a/examples/rand/rand.go b/examples/rand/rand.go index 06436c7..d7da218 100644 --- a/examples/rand/rand.go +++ b/examples/rand/rand.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/gosl/v2/slrand" "github.com/emer/gosl/v2/sltype" ) @@ -45,7 +45,7 @@ const Tol = 1.0e-4 // fails at lower tol eventually -- -6 works for many func FloatSame(f1, f2 float32) (exact, tol bool) { exact = f1 == f2 - tol = mat32.Abs(f1-f2) < Tol + tol = math32.Abs(f1-f2) < Tol return } diff --git a/files.go b/files.go index ccf8632..8ea642f 100644 --- a/files.go +++ b/files.go @@ -48,7 +48,7 @@ func AddFile(fn string, fls []string, procd map[string]bool) []string { if pd != "" { dir = sd } - if !(dir == "mat32") { + if !(dir == "math32") { if _, has := LoadedPackageNames[dir]; !has { LoadedPackageNames[dir] = true // fmt.Printf("package: %s\n", dir) diff --git a/sledits.go b/sledits.go index 64e0620..d253ec9 100644 --- a/sledits.go +++ b/sledits.go @@ -142,8 +142,8 @@ var Replaces = []Replace{ {[]byte("uint32"), []byte("uint")}, {[]byte("int32"), []byte("int")}, {[]byte("int64"), []byte("int64_t")}, - {[]byte("mat32.FastExp("), []byte("FastExp(")}, // FastExp about same speed, numerically identical - // {[]byte("mat32.FastExp("), []byte("exp(")}, // exp is slightly faster it seems + {[]byte("math32.FastExp("), []byte("FastExp(")}, // FastExp about same speed, numerically identical + // {[]byte("math32.FastExp("), []byte("exp(")}, // exp is slightly faster it seems {[]byte("math.Float32frombits("), []byte("asfloat(")}, {[]byte("math.Float32bits("), []byte("asuint(")}, {[]byte("shaders."), []byte("")}, @@ -198,7 +198,7 @@ func MathReplaceAll(mat, ln []byte) []byte { // returns true if has slrand. -- auto include that header file // if so. func SlEditsReplace(lines [][]byte) bool { - mt32 := []byte("mat32.") + mt32 := []byte("math32.") mth := []byte("math.") slr := []byte("slrand.") include := []byte("#include") diff --git a/slrand/slrand.go b/slrand/slrand.go index 85795b1..d7dca2c 100644 --- a/slrand/slrand.go +++ b/slrand/slrand.go @@ -7,7 +7,7 @@ package slrand import ( "math" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/gosl/v2/sltype" ) @@ -204,7 +204,7 @@ func BoolP(counter *sltype.Uint2, key uint32, p float32) bool { func SincosPi(x float32) (s, c float32) { const PIf = 3.1415926535897932 - s, c = mat32.Sincos(PIf * x) + s, c = math32.Sincos(PIf * x) return } @@ -217,7 +217,7 @@ func NormFloat2(counter *sltype.Uint2, key uint32) sltype.Float2 { ur := Uint2(counter, key) var f sltype.Float2 f.X, f.Y = SincosPi(Uint32ToFloat11(ur.X)) - r := mat32.Sqrt(-2. * mat32.Log(Uint32ToFloat(ur.Y))) // guaranteed to avoid 0 + r := math32.Sqrt(-2. * math32.Log(Uint32ToFloat(ur.Y))) // guaranteed to avoid 0 f.X *= r f.Y *= r return f diff --git a/sltype/README.md b/sltype/README.md index e022016..79deb1a 100644 --- a/sltype/README.md +++ b/sltype/README.md @@ -1,6 +1,6 @@ # sltype -Package `sltype` provides type definitions for standard HLSL types, using aliases to the equivalent [mat32](https://cogentcore.org/core/mat32) types where possible, but including other type names not defined there. +Package `sltype` provides type definitions for standard HLSL types, using aliases to the equivalent [math32](https://cogentcore.org/core/math32) types where possible, but including other type names not defined there. -These types will be converted to their equivalent HLSL types automatically by gosl, as will the corresponding `mat32` type names. +These types will be converted to their equivalent HLSL types automatically by gosl, as will the corresponding `math32` type names. diff --git a/sltype/float.go b/sltype/float.go index d40becc..6858fd9 100644 --- a/sltype/float.go +++ b/sltype/float.go @@ -4,16 +4,16 @@ package sltype -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" // Float is identical to a float32 type Float = float32 // Float2 is a length 2 vector of float32 -type Float2 = mat32.Vec2 +type Float2 = math32.Vec2 // Float3 is a length 3 vector of float32 -type Float3 = mat32.Vec3 +type Float3 = math32.Vec3 // Float4 is a length 4 vector of float32 -type Float4 = mat32.Vec4 +type Float4 = math32.Vec4 diff --git a/sltype/int.go b/sltype/int.go index 28d8064..2368d08 100644 --- a/sltype/int.go +++ b/sltype/int.go @@ -4,16 +4,16 @@ package sltype -import "cogentcore.org/core/mat32" +import "cogentcore.org/core/math32" // Int is identical to an int32 type Int = int32 // Int2 is a length 2 vector of int32 -type Int2 = mat32.Vec2i +type Int2 = math32.Vec2i // Int3 is a length 3 vector of int32 -type Int3 = mat32.Vec3i +type Int3 = math32.Vec3i // Int4 is a length 4 vector of int32 type Int4 struct { diff --git a/testdata/basic.go b/testdata/basic.go index 88bed56..33a13da 100644 --- a/testdata/basic.go +++ b/testdata/basic.go @@ -3,7 +3,7 @@ package test import ( "math" - "cogentcore.org/core/mat32" + "cogentcore.org/core/math32" "github.com/emer/gosl/v2/slbool" ) @@ -119,7 +119,7 @@ func (ps *ParamStruct) IntegFromRaw(ds *DataStruct, modArg *float32) { newVal = -10 } ds.Integ += newVal - ds.Exp = mat32.Exp(-ds.Integ) + ds.Exp = math32.Exp(-ds.Integ) } // AnotherMeth does more computation