Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #163223

Re: on ``vector'' and ``array''

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: on ``vector'' and ``array''
Date 2021-10-28 21:29 -0700
Organization None to speak of
Message-ID <87y26czc5u.fsf@nosuchdomain.example.com> (permalink)
References <8635oklbti.fsf@levado.to>

Show all headers | View raw


Meredith Montgomery <mmontgomery@levado.to> writes:
> I never call an array a vector because C89 doesn't even mention the word
> vector in there, but C99 does in a silly example in section 6.7.3.  What
> is your choice of terminology?  (What is an array?  What is a vector?)
>
> (*) C99 section 6.7.3
>
> --8<---------------cut here---------------start------------->8---
> [...] For example, this permits new_vector to return a vector.
>
> typedef struct { int n; float * restrict v; } vector;
> vector new_vector(int n)
> {
>   vector t;
>   t.n = n;
>   t.v = malloc(n * sizeof (float));
>   return t;
> }
> --8<---------------cut here---------------end--------------->8---
>
> Look at this example.  They're really building a convenient data
> structure there.  But is it well-named?
>
> Vectors (to me) belong to a vector space and vector spaces have
> well-defined dimensions.

That doesn't call an array a vector.  It calls a particular structure a
vector, and just in a non-normative example.

It's common to refer to array-like data structures as "vectors".  See
C++'s std::vector, for example.

And in this case, a value of this type "vector" represents (to the
extent that float values represent real numbers) a mathematical vector
in an n-dimensional vector space, where the value of n the value passed
to new_vector.  (The number of dimensions doesn't have to be a
constant.)

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-29 01:00 -0300
  Re: on ``vector'' and ``array'' Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-28 21:29 -0700
  Re: on ``vector'' and ``array'' Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-10-29 04:42 -0700
    Re: on ``vector'' and ``array'' Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-29 14:02 +0100
      Re: on ``vector'' and ``array'' Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-10-29 06:58 -0700
        Re: on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-29 12:02 -0300
          Re: on ``vector'' and ``array'' Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2021-10-30 09:33 -0700
            Re: on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-30 15:29 -0300
            Re: on ``vector'' and ``array'' Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2021-10-30 13:25 -0700
              Re: on ``vector'' and ``array'' Meredith Montgomery <mmontgomery@levado.to> - 2021-10-31 12:02 -0300
        Re: on ``vector'' and ``array'' Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-29 16:38 +0100
    Re: on ``vector'' and ``array'' Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-29 11:08 -0700

csiph-web