Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Announce: Tcl Tensor package, v4.0a1

23 views
Skip to first unread message

neil mckay

unread,
Oct 12, 2008, 8:05:41 PM10/12/08
to
The Tcl Tensor package allows for the creation and manipulation of
multidimensional numerical arrays. This is an update of code I wrote
many moons ago for work done at General Motors R&D, and previously
released in source form as the "Tns" package. The new version, 4.0a1,
updates the code to use the Tcl_Obj interface, has a TEA-compliant
build system, puts tensor commands in their own namespace, and adds a
tensor::expr command for computing tensor expressions.

This is the first alpha release, but it has a fairly complete test
suite (except that the tensor::expr command should be tested more
thoroughly), which it passes. It has been built on both Fedora Linux
and Windows XP. The code is available at http://www.eecs.umich.edu:~mckay/computer/tensor4.0a1.tar.gz

neil mckay

unread,
Oct 12, 2008, 8:11:52 PM10/12/08
to

Arjen Markus

unread,
Oct 15, 2008, 5:46:16 AM10/15/08
to
On 13 okt, 02:11, neil mckay <mc...@eecs.umich.edu> wrote:
> Whoops! The correct URL is:http://www.eecs.umich.edu/~mckay/computer/tensor4.0a1.tar.gz
>
> Neil McKay

Just out of curiosity: would it be possible to support complex
numbers too?

Regards,

Arjen

Arjen Markus

unread,
Oct 15, 2008, 5:58:55 AM10/15/08
to

When I tried to make it under Windows, it somehow failed:

cd win
nmake -f makefile.vc INSTALLDIR=c:\tcl85

gave a problem on tensorTransUtils.obj - no rule to build it.

Regards,

Arjen

neil mckay

unread,
Oct 15, 2008, 3:02:36 PM10/15/08
to
On Oct 15, 5:46 am, Arjen Markus <arjen.mar...@wldelft.nl> wrote:
>
> Just out of curiosity: would it be possible to support complex
> numbers too?
>

Complex numbers would require some fairly extensive changes. I allow a
bunch of different data types (bytes, shorts, ints, floats, and
doubles) but I assumed that all of them could be converted to/from
doubles without loss of precision. I'd have to change the code so that
my "generic" numeric type was double-complex instead. Maybe for
version 5.0...

Neil McKay

neil mckay

unread,
Oct 15, 2008, 3:10:11 PM10/15/08
to
On Oct 15, 5:58 am, Arjen Markus <arjen.mar...@wldelft.nl> wrote:
>
> When I tried to make it under Windows, it somehow failed:
>
> cd win
> nmake -f makefile.vc INSTALLDIR=c:\tcl85
>
> gave a problem on tensorTransUtils.obj - no rule to build it.
>
> Regards,
>
> Arjen


I'm glad I called this an alpha release. :-) The makefile in the "win"
directory is left over from version 3.0. I did some light editing on
it, but never tested it with the MS tools. The package does build on
WinXP if you use the GNU tools. (I successfully did a configure/make/
make test/make install under MSys.) If I can get access to Visual
Studio I might give it a try, and clean up makefile.vc. I should at
least note in the README file that the stuff in the win directory is
out of date.

Neil McKay

Arjen Markus

unread,
Oct 16, 2008, 2:44:18 AM10/16/08
to

Well, that should do the trick for me too.

Right now, I am just exploring what uses I could make of your
package. Or abuses, as the case may be :). The thing I am
interested in is both processing of large amounts of numerical
data - in the form of one-, two- or three-dimensional arrays
- and solving PDEs.

An alternative package is NAP, but I'd like to explore
yours as well :). (Tensor calculus as such is a bit out of
my league, never had any serious dealings with it ...)

Regards,

Arjen

Andreas Kupries

unread,
Oct 19, 2008, 6:53:50 PM10/19/08
to
neil mckay <mc...@eecs.umich.edu> writes:

Saw that tensor used TEA as main build system and is without big
dependencies. Plugged it into AS's buildsystem ... Last night was the
first test run and it apparently built fine on all the public
platforms, given that TEApot now contains

bluepeak:(506) ~ > teacup list Tensor
entity name version platform
------- ------ ------- ---------------------
package Tensor 4.0 hpux-parisc
package Tensor 4.0 linux-glibc2.3-ix86
package Tensor 4.0 linux-glibc2.3-x86_64
package Tensor 4.0 macosx-universal
package Tensor 4.0 solaris2.8-sparc
package Tensor 4.0 solaris2.10-ix86
package Tensor 4.0 win32-ix86
------- ------ ------- ---------------------
7 entities found

--
So long,
Andreas Kupries <akup...@shaw.ca>
<http://www.purl.org/NET/akupries/>
Developer @ <http://www.activestate.com/>
-------------------------------------------------------------------------------

Arjen Markus

unread,
Oct 22, 2008, 2:58:28 AM10/22/08
to
On 15 okt, 21:10, neil mckay <mc...@eecs.umich.edu> wrote:
> On Oct 15, 5:58 am, Arjen Markus <arjen.mar...@wldelft.nl> wrote:
>
>
> I'm glad I called this an alpha release. :-)

Hi Neil,

care for some comments?

I have put a small experiment with your package on the Wiki,
during the development of that code I came across a few
small issues:

1. tensor::expr does not like expressions on the indices, it seems.
Probably inherent to the need for generalised multiplication
and the like, but it was a little awkward.

2. some typos in the manual pages (and I could do with an HTML
version of them - have you considered using Tcllib's doctools?
Then you can generate the man pages in different formats)

3. I miss a subcommand "merge":

tensorName merge tvalue fvalue mask

where the value from tvalue is used when the mask is true
and the value from fvalue otherwise.

4. I miss a more convenient way to extract the data from a
tensor:
- writechannel gave rubbish on the screen
- storing the data in an array is somewhat unsatisfying, I'd like
a (nested) list as well

Oh well, minor issues - for my simple program it was working
very nicely indeed (thanks to Andreas for putting it in Teapot,
btw).

Regards,

Arjen

neil mckay

unread,
Oct 22, 2008, 7:49:16 PM10/22/08
to
On Oct 22, 2:58 am, Arjen Markus <arjen.mar...@wldelft.nl> wrote:

>
> Hi Neil,
>
> care for some comments?
>
> I have put a small experiment with your package on the Wiki,
> during the development of that code I came across a few
> small issues:
>
> 1. tensor::expr does not like expressions on the indices, it seems.
> Probably inherent to the need for generalised multiplication
> and the like, but it was a little awkward.

You can, of course, use the standard [expr] combined with variable or
command substitution in your tensor expression. Could get a little
tricky though...


>
> 2. some typos in the manual pages (and I could do with an HTML
> version of them - have you considered using Tcllib's doctools?
> Then you can generate the man pages in different formats)
>

I'll look at this for the next release.

> 3. I miss a subcommand "merge":
>
> tensorName merge tvalue fvalue mask
>
> where the value from tvalue is used when the mask is true
> and the value from fvalue otherwise.
>

There are ways to do this, but they take multiple statements. You
could,
for example, say

tensorName = tensor tvalue
tensorName *= tensor mask
tmp = scalar 1
tmp -= tensor mask
tmp *= fvalue
tensorName += tensor tmp

Ugly, I admit. A "merge" command might be a nice addition.

> 4. I miss a more convenient way to extract the data from a
> tensor:
> - writechannel gave rubbish on the screen
> - storing the data in an array is somewhat unsatisfying, I'd like
> a (nested) list as well
>

You should be able to just use the tensor name as an object command
to extract data:

set tList [tensorName]

should set tList to the tensor's contents, expressed as a nested Tcl
list.
You can also say, for example,

set tList [tensorName section {{1 2} {3 4}}]

if tensorName is a 2-dimensional array, and it will extract a 2-by-2
square sub-array.

> Oh well, minor issues - for my simple program it was working
> very nicely indeed (thanks to Andreas for putting it in Teapot,
> btw).
>

I also want to thank Andreas for putting it into Teapot.

Neil McKay

Arjen Markus

unread,
Oct 23, 2008, 2:13:41 AM10/23/08
to
On 23 okt, 01:49, neil mckay <mc...@eecs.umich.edu> wrote:
> On Oct 22, 2:58 am, Arjen Markus <arjen.mar...@wldelft.nl> wrote:
>
>
>
> > Hi Neil,
>
> > care for some comments?
>
> > I have put a small experiment with your package on the Wiki,
> > during the development of that code I came across a few
> > small issues:
>
> > 1. tensor::expr does not like expressions on the indices, it seems.
> >    Probably inherent to the need for generalised multiplication
> >    and the like, but it was a little awkward.
>
> You can, of course, use the standard [expr] combined with variable or
> command substitution in your tensor expression. Could get a little
> tricky though...

Just something I ran into - in my little experiment on the Wiki, I
simply
use "" instead of {} :).


>
>
>
> > 2. some typos in the manual pages (and I could do with an HTML
> >    version of them - have you considered using Tcllib's doctools?
> >    Then you can generate the man pages in different formats)
>
> I'll look at this for the next release.

Good, it would help Windows users a lot.

>
> > 3. I miss a subcommand "merge":
>
> >    tensorName merge tvalue fvalue mask
>
> >    where the value from tvalue is used when the mask is true
> >    and the value from fvalue otherwise.
>
> There are ways to do this, but they take multiple statements. You
> could,
> for example, say
>
>     tensorName = tensor tvalue
>     tensorName *= tensor mask
>     tmp = scalar 1
>     tmp -= tensor mask
>     tmp *= fvalue
>     tensorName += tensor tmp
>
> Ugly, I admit. A "merge" command might be a nice addition.
>

No hurry, just something I find very useful at times (in Fortran).

> > 4. I miss a more convenient way to extract the data from a
> >    tensor:
> >    - writechannel gave rubbish on the screen
> >    - storing the data in an array is somewhat unsatisfying, I'd like
> >      a (nested) list as well
>
> You should be able to just use the tensor name as an object command
> to extract data:
>
>     set tList [tensorName]
>
> should set tList to the tensor's contents, expressed as a nested Tcl
> list.
> You can also say, for example,
>
>     set tList [tensorName section {{1 2} {3 4}}]
>
> if tensorName is a 2-dimensional array, and it will extract a 2-by-2
> square sub-array.

Ah! Missed that bit in the documentation.

Regards,

Arjen

0 new messages