473,398 Members | 2,120 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,398 software developers and data experts.

matrices, mathematical programming

imagine that you have different matrices with different names and you
want to perform the same action with each of them. is it possible to
put their names into some array and to create a loop that would call
their names right from the array and perform the desired operations
with the members of the matrices?

Jan 26 '07 #1
9 2110
to*****@gmail.com wrote:
imagine that you have different matrices with different names and you
want to perform the same action with each of them. is it possible to
put their names into some array and to create a loop that would call
their names right from the array and perform the desired operations
with the members of the matrices?
No. You'll have to use an array of pointers for that purpose.
The program is probably poorly designed if repeated operations need to
be performed on several varyingly named objects. Use an array or linked
list of matrices.

Jan 26 '07 #2
The program is probably poorly designed if repeated operations need to
be performed on several varyingly named objects. Use an array or linked
list of matrices.
the matrices are already three-dimensional. it's a finite element
problem, a lot of different matrices with integrals... i'll have a
closer look to find the way, thanks for direction...

Jan 26 '07 #3
to*****@gmail.com wrote:
imagine that you have different matrices with different names and you
want to perform the same action with each of them. is it possible to
put their names into some array and to create a loop that would call
their names right from the array and perform the desired operations
with the members of the matrices?
Why dink around with their /names/ when you could use their /addresses/?

If your matricies have type M, have an array of type pointer-to-M and
iterate along that.

static M *matrices[] = {&M1, &M2, &M3 ...};

void desired( M *matrix ) { ... }

.... for (i = 0; i < WHATEVER; i += 1) desired( matrices[i] ); ...

--
Chris "electric hedgehog" Dollin
Meaning precedes definition.

Jan 26 '07 #4
In article <11*********************@m58g2000cwm.googlegroups. com>,
santosh <sa*********@gmail.comwrote:
>The program is probably poorly designed if repeated operations need to
be performed on several varyingly named objects.
I don't seem to catch the reasoning on that "probably poorly designed" ?
Is it not the case that any for() or while loop involving more than
one variable has "repeated operations" that "need to be performed
on several varyingly named objects" ?

Even if you meant to only talk about performing "the same operation"
on several different objects, I can think of many occasions when I would
not deem it "poor design" to perform "the same operation" on multiple
variables. Adding a routine to perform the operation on a single
variable and then calling the routine repeatedly usually does not come
for free.

Consider for example the simple example of having a long list of
[x,y] pairs and that the x and y values must be individually summed.
If one uses a routine to total one of the components and calls it
twice, then the long list must be traversed twice, with all the cache
effects that implies -- and if it is a linked list, with noticable
pointer work. Is it really such a bad design to use a single
routine that iterates over all the members and sums the
"several varyingly named objects" in individual statements? Is
the meaning unclear? Is it hard to debug or maintain or document?
Worse than introducing a new auxillary routine just for this
one purpose?
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell
Jan 26 '07 #5
thank you all. this was the first time i posted anything here and i see
i can meet good people around here... thanks a lot for your help...

On Jan 26, 3:20 pm, Chris Dollin <chris.dol...@hp.comwrote:
toma...@gmail.com wrote:
imagine that you have different matrices with different names and you
want to perform the same action with each of them. is it possible to
put their names into some array and to create a loop that would call
their names right from the array and perform the desired operations
with the members of the matrices?Why dink around with their /names/ when you could use their /addresses/?

If your matricies have type M, have an array of type pointer-to-M and
iterate along that.

static M *matrices[] = {&M1, &M2, &M3 ...};

void desired( M *matrix ) { ... }

.... for (i = 0; i < WHATEVER; i += 1) desired( matrices[i] ); ...

--
Chris "electric hedgehog" Dollin
Meaning precedes definition.
Jan 26 '07 #6
Walter Roberson wrote:
In article <11*********************@m58g2000cwm.googlegroups. com>,
santosh <sa*********@gmail.comwrote:
The program is probably poorly designed if repeated operations need to
be performed on several varyingly named objects.

I don't seem to catch the reasoning on that "probably poorly designed" ?
Is it not the case that any for() or while loop involving more than
one variable has "repeated operations" that "need to be performed
on several varyingly named objects" ?
No. The OP wanted to repeatedly process multiple objects by using their
*name*. That is, IMHO, poor design. Lets say you have a series of
objects called o1, o2, ..., oN. The OP was asking, as far as I can
figure out from his post, if it was possible to store these identifiers
in an array, and pass them, one by one, to the processing function.
This is not possible in C, so I suggested that he use an array of
pointers to these objects, or a linked list, to pass them around to
various functions.
Even if you meant to only talk about performing "the same operation"
on several different objects, I can think of many occasions when I would
not deem it "poor design" to perform "the same operation" on multiple
variables. Adding a routine to perform the operation on a single
variable and then calling the routine repeatedly usually does not come
for free.
You're quite right in pointing out the above. My choice of wording was
really bad. I didn't mean to imply that performing repeated operations
on varyingly named objects was bad, just that attempting to use each
one by it's name, instead of by means of pointers, was probably poor
design.

Reading over my own post, I realise I ended up seeming to mean
something totally different.

Jan 26 '07 #7
on varyingly named objects was bad, just that attempting to use each
one by it's name, instead of by means of pointers, was probably poor
design.
yes, it is a sign of poor design. i agree....

Jan 26 '07 #8
to*****@gmail.com wrote:
>
thank you all. this was the first time i posted anything here and
i see i can meet good people around here... thanks a lot for your
help...
Please do not top-post. Your answer belongs after (or intermixed
with) the (snipped) material to which you reply. The snipping
removes anything immaterial to your reply. See the following
links.

--
Some informative links:
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/ (taming google)
<http://members.fortunecity.com/nnqweb/ (newusers)
Jan 26 '07 #9

<to*****@gmail.comwrote in message
imagine that you have different matrices with different names and you
want to perform the same action with each of them. is it possible to
put their names into some array and to create a loop that would call
their names right from the array and perform the desired operations
with the members of the matrices?
C binds identifiers at compile time.

Or, in less geeky terms, all the human-readbale labels you use for your
matrices are thrown away, and the computer just works on addresses.

Whilst it is possible to fudge up some name binding system, by turning the
names into strings and implenting a look-up table, if you need to do this
then C is probably not the right language for your problem.
However most functions to tkae lists of matrices can be written without
names

eg

super_op(double **matrices, int *width, int *height, int Nmatrices)

Then you have to do all the row|column converions to offsets manually
Jan 26 '07 #10

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

Similar topics

1
by: Nils Wagner | last post by:
Hi all, Has someone written a C binding to transfer matrices from C to Python and vice versa ? Any pointer would be appreciated. Nils
3
by: gelong | last post by:
Hi there, I have a problem in writing a mathematical function using C++ programming. How to write an input that can insert whole equation? Example is the input are x˛ + 3y - 4zł = 0. In maple, it...
3
by: Prototipo | last post by:
Hi! I need to dynamically create X vectors of matrices (with a known size of 5x5). It's like a three-dimensional matrix with 2 known dimensions and the third unknown. I have something like: ...
1
emaghero
by: emaghero | last post by:
Does anybody know an algorithm for the fast multiplication of three n-x-n symmetric matrices? I have an algorithm, which I'm not too pleased with, that does the job. Does anybody know a faster...
4
by: Talbot Katz | last post by:
Greetings Pythoners! I hope you'll indulge an ignorant outsider. I work at a financial software firm, and the tool I currently use for my research is R, a software environment for statistical...
5
by: td0g03 | last post by:
This program adds two square matrices - Algorithm 1-3, Page 35. Change it to implement the generalized algorithm to add two m x n matrices. Matrices, in general, are not square or n x n...
2
by: debiasri | last post by:
I have to devide a matrix in variable no of matrices with each having variable no of rows. Like I have to devide a matrix with dim.9X19 into say 4 matrices with row nos 1,6,6,6 respectively, and I...
13
by: jacek.strzelczyk | last post by:
Hello, I'm looking for a C library that provides the notation of n- dimensional mathematical functions. Or is there any other way to decode that kind of functions in C language? Thanks in...
5
by: adinda | last post by:
So what i need is this; (I'm very new at this,, programming in C I mean...) In matlab I had a while loop, and after each loop was done I added my resulting matrix to an object. Seeing the loop...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.