Chris Green

@aachrisg@mastodon.gamedev.place
58 Followers
65 Following
162 Posts
Back at Valve. gfx,simulation,parallelism,math,AI,HW,VR,game engines. MTG Online,Ultima Underworld,AmigaOS,Flight Sim,Scuba,Paleontology. ~40years experience.
The least toxic and most interesting social networkhttps://www.goodreads.com/user/show/28185427-chris-green

c++
std::transform( a.begin(), a.end(), b.begin(), []( int x ){ return func(2*x; } );

my language:
b[] = func( 2 *a[] )

- generates an efficient for loop
- no back inserter needed for std::vector type things.

I used to think the heaviside function (x>=0)?1:0 was called that because it's "heavy" on one side and empty on the other. It's actually named after mathematician Oliver Heaviside.
C++ tip: For complex template classes, you should explicitly instantiate them with likely parameters somewhere, such as test code. This will find compilation errors in methods that wouldn't otherwise show up until someone tries to call them in a similar instantiation.

dist keyworld for distributed processing in my c++ preprocessor based language:

dist var state : solver // create the var on all nodes

state.iterate() // one iteration on the local copy
dist state.iterate() // iterate on all nodes

var flBest = dist min( state.residual ) // reduction across all nodes

The homelab world really needs a cheap basic functional 4/5 port 10gb rj45 switch in the <$50 range

generated c++ code:

sexpr myList = cons( 1, cons( 2, cons( 3, NIL);
int nOne = car( myList); // exception if type mismatch.
flDet = det( myMatrix );

In my custom c++ preprocesor based language I added the ability to define custom prefix operators. They end up being like function calls w/o mandatory parens.

var myList :sexpr = $( 1 2 3 ),
nOne :int = car myList

flDet = det myMatrix //calc determinant

Firing up a few cores to do some math
I'm digging this syntax in my preprocessor-based language:
myData[].m_nCount = 0 // set count field of every element
F( data[]) // call f on every element of data
workitems[].Execute() // call method on every element
C++ linear algebra opinion: operator* should be matrix mul, only taking valid combinations of dimensions. vec3d*vec3d is invalid. v1*v2.transpose() is legal as is v1.Dot(v2). If you want the Hadamard product, you should call a .Hadamard() or .ComponentWiseMultiply() method. For 1d vectors, there should be both column and row vector variants and ones that have an implicit 1 or 0 added for use with projection matrices etc. Constraining operations like this is like strong type checking for math.