Topic: Preliminary opinions on a tensor class?


Author: VinceRev <vince.rev@gmail.com>
Date: Tue, 22 Oct 2013 15:02:59 -0700 (PDT)
Raw View
------=_Part_3743_29960775.1382479379288
Content-Type: text/plain; charset=ISO-8859-1

Hello.

A while ago, I was wondering about "as small vector/matrix" library in C++
because when we do computer graphics and science we need them everywhere.

The problem is that the issue of small vectors/matrices is oftenly
considered globally, and we end up with infinite discussions about sparse
matrices and optimizations for 100x100 or 1000x1000 matrices. But I think
that a Vector3D does not have the same purpose as a 1000x1000 matrice.

And now that there is a 2D graphics working group we may have to solve the
problem of Vector2D/Vector3D and related transformation matrices. I think
that implementing a vector2d for 2D graphics would be too specific and we
need a global approach on that problem.

I realized that in fact, we do not need a library of small vectors: we need
a library of tensors. For those who are not familiar with multilinear
algebra, a tensor is a very generic and well defined mathematical object
(http://en.wikipedia.org/wiki/Tensor). Scalars, vectors (and as far as I
know, objects like rotation matrices) are specific cases of tensors.

So do you think that there is a room for a tensor class/library into C++?

Basically, a generic tensor would look like to:
tensor<typename Type, size_t Dimension, size_t Covariant, size_t
Contravariant>
so a 3D vector would be: tensor<double, 3, 1>

I personnally think that this is the most generic approach to address a lot
of standard problems into computer graphics and science (and many libraries
redefine their own vector2d, vector3d etc...). For the moment, I do not
have any clear proposal, but I think that I would easily be able to find
scientists interested in working on such a thing if the community see this
as relevant.

Thank you very much.


--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_3743_29960775.1382479379288
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello.<br><br>A while ago, I was wondering about "as small=
 vector/matrix" library in C++ because when we do computer graphics and sci=
ence we need them everywhere. <br><br>The problem is that the issue of smal=
l vectors/matrices is oftenly considered globally, and we end up with infin=
ite discussions about sparse matrices and optimizations for 100x100 or 1000=
x1000 matrices. But I think that a Vector3D does not have the same purpose =
as a 1000x1000 matrice. <br><br>And now that there is a 2D graphics working=
 group we may have to solve the problem of Vector2D/Vector3D and related tr=
ansformation matrices. I think that implementing a vector2d for 2D graphics=
 would be too specific and we need a global approach on that problem.<br><b=
r>I realized that in fact, we do not need a library of small vectors: we ne=
ed a library of tensors. For those who are not familiar with multilinear al=
gebra, a tensor is a very generic and well defined mathematical object (htt=
p://en.wikipedia.org/wiki/Tensor). Scalars, vectors (and as far as I know, =
objects like rotation matrices) are specific cases of tensors.<br><br>So do=
 you think that there is a room for a tensor class/library into C++? <br><b=
r>Basically, a generic tensor would look like to:<br>tensor&lt;typename Typ=
e, size_t Dimension, size_t Covariant, size_t Contravariant&gt;<br>so a 3D =
vector would be: tensor&lt;double, 3, 1&gt;<br><br>I personnally think that=
 this is the most generic approach to address a lot of standard problems in=
to computer graphics and science (and many libraries redefine their own vec=
tor2d, vector3d etc...). For the moment, I do not have any clear proposal, =
but I think that I would easily be able to find scientists interested in wo=
rking on such a thing if the community see this as relevant.<br><br>Thank y=
ou very much.<br><br><br></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_3743_29960775.1382479379288--

.


Author: shadowdrak@gmail.com
Date: Sat, 2 Nov 2013 16:26:53 -0700 (PDT)
Raw View
------=_Part_340_24411877.1383434813384
Content-Type: text/plain; charset=ISO-8859-1

The problem I see is that once you go beyond a single dimension, there are
non trival decisions and trade-offs to make(i.e. Row major versus Column
major, sparse versus dense). Do we want only effectively multidimensional
arrays, or do we want it to support fully fledged (multi-) linear algebra.
The decisions are often deeply tied to the problem domain. Scientist have
different goals than graphics programmers. One size does not fit all. These
are often difficult decisions.

In the following I will try not to be too technical:
The other thing is that your general form for the type template is not
quite right. There are essentially two different ways to treat tensors, and
you seem to be mixing the two conceptually. One way of thinking about it is
as something along the lines of multidimensional arrays. For a tensor of
this sort you need a variadic template(each dimension can have it's own
size).

The other way of looking at tensors is as a way of generating new vector
fields from ones we already know, by associating it in a special way to the
cartesian product of the two input vector fields. A template type for this
wouldn't need to be variadic, but it would take two type parameters(not a
dimension) and a base field.

Again what you want depends on your target audience.

-Tim

On Wednesday, October 23, 2013 12:02:59 AM UTC+2, VinceRev wrote:
>
> Hello.
>
> A while ago, I was wondering about "as small vector/matrix" library in C++
> because when we do computer graphics and science we need them everywhere.
>
> The problem is that the issue of small vectors/matrices is oftenly
> considered globally, and we end up with infinite discussions about sparse
> matrices and optimizations for 100x100 or 1000x1000 matrices. But I think
> that a Vector3D does not have the same purpose as a 1000x1000 matrice.
>
> And now that there is a 2D graphics working group we may have to solve the
> problem of Vector2D/Vector3D and related transformation matrices. I think
> that implementing a vector2d for 2D graphics would be too specific and we
> need a global approach on that problem.
>
> I realized that in fact, we do not need a library of small vectors: we
> need a library of tensors. For those who are not familiar with multilinear
> algebra, a tensor is a very generic and well defined mathematical object (
> http://en.wikipedia.org/wiki/Tensor). Scalars, vectors (and as far as I
> know, objects like rotation matrices) are specific cases of tensors.
>
> So do you think that there is a room for a tensor class/library into C++?
>
> Basically, a generic tensor would look like to:
> tensor<typename Type, size_t Dimension, size_t Covariant, size_t
> Contravariant>
> so a 3D vector would be: tensor<double, 3, 1>
>
> I personnally think that this is the most generic approach to address a
> lot of standard problems into computer graphics and science (and many
> libraries redefine their own vector2d, vector3d etc...). For the moment, I
> do not have any clear proposal, but I think that I would easily be able to
> find scientists interested in working on such a thing if the community see
> this as relevant.
>
> Thank you very much.
>
>
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_340_24411877.1383434813384
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">The problem I see is that once you go beyond a single dime=
nsion, there are non trival decisions and trade-offs to make(i.e. Row major=
 versus Column major, sparse versus dense). Do we want only effectively mul=
tidimensional arrays, or do we want it to support fully fledged (multi-) li=
near algebra. The decisions are often deeply tied to the problem domain. Sc=
ientist have different goals than graphics programmers. One size does not f=
it all. These are often difficult decisions.<div><br><div>In the following =
I will try not to be too technical:</div><div>The other thing is that your =
general form for the type template is not quite right. There are essentiall=
y two different ways to treat tensors, and you seem to be mixing the two co=
nceptually. One way of thinking about it is as something along the lines of=
 multidimensional arrays. For a tensor of this sort you need a variadic tem=
plate(each dimension can have it's own size).</div><div><br></div><div>The =
other way of looking at tensors is as a way of generating new vector fields=
 from ones we already know, by associating it in a special way to the carte=
sian product of the two input vector fields. A template type for this would=
n't need to be variadic, but it would take two type parameters(not a dimens=
ion) and a base field.</div><div><br></div><div>Again what you want depends=
 on your target audience.</div><div><br></div><div>-Tim</div><div><br>On We=
dnesday, October 23, 2013 12:02:59 AM UTC+2, VinceRev wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #=
ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Hello.<br><br>A while ago, I=
 was wondering about "as small vector/matrix" library in C++ because when w=
e do computer graphics and science we need them everywhere. <br><br>The pro=
blem is that the issue of small vectors/matrices is oftenly considered glob=
ally, and we end up with infinite discussions about sparse matrices and opt=
imizations for 100x100 or 1000x1000 matrices. But I think that a Vector3D d=
oes not have the same purpose as a 1000x1000 matrice. <br><br>And now that =
there is a 2D graphics working group we may have to solve the problem of Ve=
ctor2D/Vector3D and related transformation matrices. I think that implement=
ing a vector2d for 2D graphics would be too specific and we need a global a=
pproach on that problem.<br><br>I realized that in fact, we do not need a l=
ibrary of small vectors: we need a library of tensors. For those who are no=
t familiar with multilinear algebra, a tensor is a very generic and well de=
fined mathematical object (<a href=3D"http://en.wikipedia.org/wiki/Tensor" =
target=3D"_blank">http://en.wikipedia.org/wiki/<wbr>Tensor</a>). Scalars, v=
ectors (and as far as I know, objects like rotation matrices) are specific =
cases of tensors.<br><br>So do you think that there is a room for a tensor =
class/library into C++? <br><br>Basically, a generic tensor would look like=
 to:<br>tensor&lt;typename Type, size_t Dimension, size_t Covariant, size_t=
 Contravariant&gt;<br>so a 3D vector would be: tensor&lt;double, 3, 1&gt;<b=
r><br>I personnally think that this is the most generic approach to address=
 a lot of standard problems into computer graphics and science (and many li=
braries redefine their own vector2d, vector3d etc...). For the moment, I do=
 not have any clear proposal, but I think that I would easily be able to fi=
nd scientists interested in working on such a thing if the community see th=
is as relevant.<br><br>Thank you very much.<br><br><br></div></blockquote><=
/div></div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_340_24411877.1383434813384--

.


Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Sun, 3 Nov 2013 00:39:10 +0100
Raw View
--089e013a10368e84b904ea3a3039
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Nov 3, 2013 at 12:26 AM, <shadowdrak@gmail.com> wrote:

> Again what you want depends on your target audience.


The question is then, could this tensor abstraction either:
 - be used as an implementation detail of higher-level abstractions closer
to domain-specific needs;
 - be used as an intermediate abstract representation of higher-level
abstractions closer to domain-specific needs.

Without an example implementation of such tensor abstraction, it's really
hard to say (I'm more a user of graphics library than a scientist).

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--089e013a10368e84b904ea3a3039
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On Sun, Nov 3, 2013 at 12:26 AM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:s=
hadowdrak@gmail.com" target=3D"_blank">shadowdrak@gmail.com</a>&gt;</span> =
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Again what you want depends on your target a=
udience.</blockquote></div><br>The question is then, could this tensor abst=
raction either:</div>
<div class=3D"gmail_extra">=A0- be used as an implementation detail of high=
er-level abstractions closer to domain-specific needs;</div><div class=3D"g=
mail_extra">=A0- be used as an intermediate abstract representation of high=
er-level abstractions closer to domain-specific needs.</div>
<div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra">Without an =
example implementation of such tensor abstraction, it&#39;s really hard to =
say (I&#39;m more a user of graphics library than a scientist).</div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--089e013a10368e84b904ea3a3039--

.


Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Sun, 3 Nov 2013 15:53:59 +0100
Raw View
--001a11c3367631ad1104ea46f8d0
Content-Type: text/plain; charset=ISO-8859-1

>
> I think judging by your response that it would make sense to first take a
> look at designing a suitable abstraction. I find the idea interesting
> enough to look at it deeper myself.
> I think it might be possible to have both things. The tensor concept is
> potentially a powerful product type mechanism akin to pair. Of course that
> won't make it automatically useful. In graphics the most common tensors are
> scalars, vectors and matrices. There are already libraries which do those
> well. Some physics applications might require higher-order tensors, but
> mostly tensors are just a useful mathematical abstraction. They formally
> are just the set of linear transformations between two sets(well not
> precisely, but nevermind). Doesn't seem intrinsically useful for general
> purpose programming except as maybe a replacement for ad-hoc
> multidimensional containers.
> If I come up with something that might look useful, I will post it to the
> group.
> -Tim


Maybe contact privately VinceRev about this.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11c3367631ad1104ea46f8d0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-colo=
r:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I think judgin=
g by your response that it would make sense to first take a look at designi=
ng a suitable abstraction. I find the idea interesting enough to look at it=
 deeper myself.<br>
I think it might be possible to have both things. The tensor concept is pot=
entially a powerful product type mechanism akin to pair. Of course that won=
&#39;t make it automatically useful. In graphics the most common tensors ar=
e scalars, vectors and matrices. There are already libraries which do those=
 well. Some physics applications might require higher-order tensors, but mo=
stly tensors are just a useful mathematical abstraction. They formally are =
just the set of linear transformations between two sets(well not precisely,=
 but nevermind). Doesn&#39;t seem intrinsically useful for general purpose =
programming except as maybe a replacement for ad-hoc multidimensional conta=
iners.<br>
If I come up with something that might look useful, I will post it to the g=
roup.<br><span style=3D"font-family:arial,sans-serif;font-size:12.727272033=
691406px">-Tim</span></blockquote><div><span style=3D"font-family:arial,san=
s-serif;font-size:12.727272033691406px"><br>
</span></div><div><span style=3D"font-family:arial,sans-serif;font-size:12.=
727272033691406px">Maybe contact privately VinceRev about this.</span></div=
><div><span style=3D"font-family:arial,sans-serif;font-size:12.727272033691=
406px"><br>
</span></div></div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11c3367631ad1104ea46f8d0--

.


Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Sun, 3 Nov 2013 15:54:51 +0100
Raw View
--047d7b41c0ba47dad704ea46fb8b
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Sun, Nov 3, 2013 at 3:53 PM, Klaim - Jo=EBl Lamotte <mjklaim@gmail.com>w=
rote:

> Maybe contact privately VinceRev about this.


Because he is apparently working at something like such a tensor
abstraction and I'm sure any help would be welcome.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--047d7b41c0ba47dad704ea46fb8b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On Sun, Nov 3, 2013 at 3:53 PM, Klaim - Jo=EBl Lamotte <span dir=3D"ltr">&l=
t;<a href=3D"mailto:mjklaim@gmail.com" target=3D"_blank">mjklaim@gmail.com<=
/a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Maybe contact privately VinceRev about this.=
</blockquote></div><br>Because he is apparently working at something like s=
uch a tensor abstraction and I&#39;m sure any help would be welcome.</div>
</div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7b41c0ba47dad704ea46fb8b--

.