Previous Page Next Page Contents

linalg::vecdim -- number of components of a vector

Introduction

linalg::vecdim(v) returns the number of elements of the vector v.

Call(s)

linalg::vecdim(v)

Parameters

v - a vector, i.e., an n x 1 or 1 x n matrix of a domain of category Cat::Matrix

Returns

a positive integer.

Related Functions

linalg::matdim, linalg::ncols, linalg::nrows

Example 1

We define a column vector with two elements and a row vector with four elements:

>> v1 := matrix([1, 0]); v2 := matrix([[1, 2, 3, 4]])
                                  +-   -+
                                  |  1  |
                                  |     |
                                  |  0  |
                                  +-   -+
      
                              +-          -+
                              | 1, 2, 3, 4 |
                              +-          -+

linalg::vecdim gives us the number of elements, i.e., the dimension of these vectors:

>> linalg::vecdim(v1), linalg::vecdim(v2)
                                   2, 4

In contrast, the function linalg::matdim returns the number of rows and columns of these vectors:

>> linalg::matdim(v1), linalg::matdim(v2)
                              [2, 1], [1, 4]

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000