Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc. |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.*From*: Massimiliano Janes <max.jns@xxxxxxxxx>*Date*: Mon, 9 Jan 2017 09:33:34 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=6jwPvvT9MT5sfrsnIkcLiNcCf+eYlb1i/sexe6WGxvQ=; b=ByLc3cBczeMZM2CZVwMr5rUxWYiS026rWz7GONdbmV6K+4ZV0a1fG9im43smY4/EDs P45mpXx/ElSfEn8Bq8/JcRWz6d5bnxCMxCra5+YNUMJaGse8j1cJ5s7q82jyuILCm40t HNkeZOVMLw29MkEqeD6RFfOCnmMfLPgeeCdw/fo74QmJalnEDHI1fim5YL3bL/50Zowm QG1z7ku+v/sCL0LMKbO3VPTZc/8N1/azF6R6tYUNqH0JfejgvJj4E7oydMOtcXGW/n23 wOhK+XzyjgINHvuI2zo9rzi+dpYA2iVNSn12k/K5hiUdrSI349jURoT2Q1UzBN8BLYpD 596w==

> On 8 Jan 2017, at 15:01, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote: > > 3) Before pushing too much towards fancy syntax, thinking about it, here is yet another variation on the theme of expression based api, similar to iota but with the benefit of more closely following elementary math notation , allowing multidimensional generalizations, matrix operations via Einstein-like summation convention, and possibly a new initialization syntax: given 'letter' symbols ( ala std::placeholders ) _i,_j,_k,... _iN,_jN,_kN... ans a set of allowed 'arithmetic' expressions f(_i,_iN) _i*2+1, -1 -_i, ... generating the intersection of { f(i,N) % N |0<=i<N} && {0<=i<N}, where N is the deduced size of the target object and a set of allowed 'boolean' expressions g(_i,_iN) generating { 0<=i<N | g(i,N) }, where N is the deduced size of the target object and compound expressions (f|g) generating the intersection of the results f and g we can write ( with obvious meaning ) A(_i) A(_i<k) A(2+_i | _i<k) A(2+_i*3 | _i<k) A(_i|_i<=_iN-k) // up to last kth, no special convention, follows from definition A(-1-_i) // the reverse of A, the -1 follows from the definition; less natural than just '-iota', but ok IMO A(-1-2*_i) // even reverse *starting* form last A( -1 -_i | _i%2 == 0 ) // even indices in reverse, this is not the same as the above // multidimensional A(_i,_j) // as A A(_i,_i) // as A.diagonal() // operation ( assuming column indices as covariant, and *operator as lowering indices ) A(_i,_j) * A(_j,_k) // matrix product A(_i) * A(*_i) // vector dot product A(_i,_i) * A(*_i,_*i) // matrix trace // boolean expressions with lambdas A( _i | []( auto i ){ return i >= 3 && i <= i.N - 5; } ) // runtime only, the 'i' being an index wrapper with obvious member N ( _iN <-> i.N ) A( _i | [](auto i){ return boolean_fun(i,i.n()); } ) // initialization Vector3f{ _i << 2.f } // as Vector3f::Constant Vector3f{ _i << _iN - 2 * _i } // linear epressions Vector3f{ _i << []( auto i ){ return i.n() - 2 * i; } } // lambdas Matrix3f{ (_i,_j) << 2.f } // as Matrix3f::Constant Matrix3f{ (_i,_j) << []( auto i, auto j ){ return i == j ? 0.f : 1.f; } } // Dirac's and friends ... … more ? unless I'm missing somthing, this should be implementable ( it's till to decide what expressions are to be allowed where, when to allow compile/run time evaluation or not, etc… ) and require no special convention apart remembering the i,j,iN,,… placeholders and the simple generating rules aforementioned. what do you think ?

**Follow-Ups**:**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**References**:**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Yuanchen Zhu

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Yuanchen Zhu

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Yuanchen Zhu

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Yuanchen Zhu

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Massimiliano Janes

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Yuanchen Zhu

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Yuanchen Zhu

**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.** - Next by Date:
**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.** - Previous by thread:
**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.** - Next by thread:
**Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |