473,395 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Tensor

Dear All!

I faced a problem when implementing class Tensor. The idea is
simple - give a rank as an input to produce a tensor of rank n.
But how to do it programmatically w/o the use of any "if
then" statements? At the moment I have a large number of classes
Tensor_N, which doesn't look nice, and doesn't fit to the problem I'm
trying to solve.
for rank one I need *array, for 2 **array, for 3 ***array, etc.
Is there any way to make it as a black box?
For instance, create a string beginning with n stars and use it in
the code??? A tiny code-snippet would be extremely helpful to catch the
general idea. Certainly, if it is possible at all.

Cheers.
Akyl.

Jul 22 '05 #1
2 1580
Akyl Tulegenov <pc****@unix.ccc.nottingham.ac.uk> wrote in
news:Pi**************************************@gran by.ccc.nottingham.ac.uk:
Dear All!

I faced a problem when implementing class Tensor. The idea is
simple - give a rank as an input to produce a tensor of rank n.
But how to do it programmatically w/o the use of any "if
then" statements? At the moment I have a large number of classes
Tensor_N, which doesn't look nice, and doesn't fit to the problem I'm
trying to solve.
for rank one I need *array, for 2 **array, for 3 ***array, etc.
Is there any way to make it as a black box?
For instance, create a string beginning with n stars and use it in
the code??? A tiny code-snippet would be extremely helpful to catch the
general idea. Certainly, if it is possible at all.


As I understand, you need a multi-dimensional array.
Here's the first hit I got from google on the subject:
http://www.codeproject.com/cpp/multi..._using_TMP.asp

--
:: bartekd [at] o2 [dot] pl

Jul 22 '05 #2
>
As I understand, you need a multi-dimensional array.
Here's the first hit I got from google on the subject:
http://www.codeproject.com/cpp/multi..._using_TMP.asp


That's definitely the technique to go for, but also have a look at the boost
version

http://www.boost.org/libs/multi_array/doc/index.html

john
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Akyl Tulegenov | last post by:
Dear All! this is a construct I use to create the tensor of rank 2 in C. double **dtensor2(long nl1,long nh1,long nl2,long nh2){ double **tensor=NULL; long i1,i2; tensor=(double...
9
by: Steven T. Hatton | last post by:
The following works: template <typename T> struct ID3M{ static const T ID; }; template <typename T> const T ID3M<T>::ID = {{1,0,0},{0,1,0},{0,0,1}};
2
by: Drew McCormack | last post by:
I have a self written Tensor class which I need to write a number of elementwise operations for (eg sin, cos, abs, conj). I am trying to implement most of these in terms of standard library...
2
by: aitrob | last post by:
Hi, I have a problem concerning templates/inheritance. I have a code that compiles fine with g++ 4.0.1 (Apple version), but gives a lot of errors with Intel C++ 10.1 (Mac OS X). I'm not sure if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.