Small Vectors Proposal
    Benji Smith 
    dlanguage at benjismith.net
       
    Tue Jan 30 14:10:33 PST 2007
    
    
  
Mikola Lysenko wrote:
> After thinking about it some more, I believe this approach would 
> probably work just as well.  Another possibility is to simply restrict 
> vectors to floating point types only:
> 
> ie, float2, float3, float4, double2, double3, double4, real2, real3, real4.
> 
> This makes the number of new types only 9 instead of 57.  The 
> disadvantage is that it is no longer easy to use the MMX extensions 
> which are specially tailored for integer vectors.  Overall, I guess I'd 
> be happy with either situation.
Three and four dimensional vectors are nice for physics and whatnot, but 
  for those of us in the machine-learning field, it's commonplace to 
construct vectors (and to calculate distances, dot-products, and cosines 
between those vectors) using many many more dimensions.
Right now, I'm working on a statistical prediction algorithm that uses 
sparse 300,000-dimensional feature vectors. There's no reason to limit 
SSE optimizations to small-dimensionality vectors.
I don't think having special datatypes is the right solution. I think it 
should be possible to annotate any array with a flag that says "I'll be 
doing vector math here. Watch out for possible optimizations".
Or just having a library of vector functions would probably be 
sufficient to solve the problem in the majority of cases.
--benji
    
    
More information about the Digitalmars-d
mailing list