comp.lang.ada
 help / color / mirror / Atom feed
From: faryumg@gmail.com
Subject: Re: how to copy complete column (or row) of matrix to another?
Date: Tue, 5 Sep 2017 22:34:35 -0700 (PDT)
Date: 2017-09-05T22:34:35-07:00	[thread overview]
Message-ID: <1d996595-5b16-4f66-8a50-7dfb1165fb27@googlegroups.com> (raw)
In-Reply-To: <oonat2$crh$1@gioia.aioe.org>

On Tuesday, September 5, 2017 at 4:10:32 PM UTC-7, Nasser M. Abbasi wrote:
> 
> Thank you Randy for the answer. Ok. I understand. But
> this unfortunately takes Ada out of possible languages
> to use for me for now. I am planning to take numerical
> course where we have choice to use Fortran or Matlab or
> another language, but without being able to do such
> common operations on matrices, (without writing
> much more code) I will now look at using Fortran
> or Matlab for this.

I agree that this is a serious shortcoming of Ada. But like Randy said, you can have arrays of arrays which probably isn't a great solution if you are going to do lots of numerical stuff (OK for "computer sciencey" stuff I suppose). I think possibly a better solution is to use normal matrices such as you defined in your example and you can write just a few little functions that will do the copying for you; you can make them look fairly readable if not quite as nice as Fortran or Matlab. And don't forget that Ada now has built-in vector and matrix types for real and complex numbers, with overloaded operators.

You can also write your own overloads so that can do essentially "mixed-mode" arithmetic so that you can write mathematical code without considering walking into traffic with your eyes closed because of all the type conversions. Or I can send you mine if you like. I've made overloaded operators for integer, real, imaginary, and complex numbers as well as several array types--there are a lot of them but they are easy to write.

Ada's strong typing makes e.g. the three ways of vector multiplication interesting. I have three "*" operators for vectors and the three kinds of multiplication are made unambiguous because of the return type. Consider

a := b * c;

where b and c are vectors. If a is a scalar, then b * c is the inner or "dot" product. If a is a vector, then b * c is a element-by-element multiplication. And if a is a matrix, then b * c is the outer product. Pretty neat, huh.

Jerry

  reply	other threads:[~2017-09-06  5:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05  8:41 how to copy complete column (or row) of matrix to another? Nasser M. Abbasi
2017-09-05 22:45 ` Randy Brukardt
2017-09-05 23:10   ` Nasser M. Abbasi
2017-09-06  5:34     ` faryumg [this message]
2018-03-21 13:58       ` Marius Amado-Alves
2018-03-30 21:25         ` gerdien.de.kruyf
2017-09-06  7:17     ` Simon Wright
2017-09-06  7:31   ` Dmitry A. Kazakov
2017-09-09 22:33 ` darek
2017-09-09 22:48 ` darek
2017-09-12 12:57   ` Lucretia
2017-10-02 23:08     ` Randy Brukardt
2017-09-12 21:22 ` Johan Söderlind Åström
2017-09-17 12:01 ` Robert Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox