bugGNU Octave - Bugs: bug #60515, trace documentation


bug #60515: trace documentation

Submitted by:  None
Submitted on:  Tue 04 May 2021 08:39:44 AM UTC  
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  None Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  6.2.0
Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 04 May 2021 09:27:16 PM UTC, comment #1: 

It's generally understood from linear algebra that trace() applies to 2-D matrices.  Matlab also doesn't bother to document that N-dimensional arrays are excluded.

If you need a trace of a 2-D projection then you will need to use a for loop as you asked.  For example,

A = rand (3,3,3);
T = zeros (3,1);
for i = 1:3
  T(i) = trace (A(:,:,i));

Rik <rik5>
Project Administrator
Tue 04 May 2021 08:39:44 AM UTC, original submission:  

error: trace: only valid on 2-D objects
error: called from
    trace at line 37 column 5

Expected x to consist of 3 values.

The documentation is not clear about this:

## -*- texinfo -*-
## @deftypefn {} {} trace (@var{A})
## Compute the trace of @var{A}, the sum of the elements along the main
## diagonal.
## The implementation is straightforward: @code{sum (diag (@var{A}))}.
## @seealso{eig}
## @end deftypefn

The error is more clear.


Having many DCM and doing the trace.
Does this need to done in a loop?



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    No changes have been made to this item

    Back to the top

    Powered by Savane 3.6