patchGNU Octave - Patches: patch #7632, sub2ind and ind2sub for tringular...

 
 

patch #7632: sub2ind and ind2sub for tringular matrices

Submitter:  Juan Pablo Carbajal <juanpi>
Submitted:  Wed 12 Oct 2011 04:22:34 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Wont Do Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 20 Nov 2012 03:46:35 PM UTC, comment #1: 

Can be closed.
Reason: not a patch.

I will generate a proper change set in the future

Juan Pablo Carbajal <juanpi>
Group Member
Wed 12 Oct 2011 04:22:34 PM UTC, original submission:  


This is related to
http://octave.1599824.n4.nabble.com/Re-OctDev-sub2ind-for-Upper-triangular-matrices-td3845392.html

Attached find two functions that do what is required. They are vectorized.
sub2ind_tril is using sub2ind, maybe there is a more efficient way of doing this.

To merge ind2sub_tril with current ind2sub one needs to add a check for string arguments and modify the docstring. Also, ind2sub_tril returns a row matrix.

## @deftypefnx {Function File} { @var{ind} = } sub2ind (@dots{}, @var{type})

## where @var{type} can be 'triu' or 'tril'

The body reads

type_str = varargin{ cellfun (@ischar, varargin) }
if !isempty (type_str)

 ind = sub2ind_tril (N, row, col)
 return
end

To merge sub2ind_tril with current sub2ind. change the docstring similarly as before, and the body of the function reads

type_str = varargin{ cellfun (@ischar, varargin) }
if !isempty (type_str)

 [r c] = ind2sub_tril (N, ind)

 if strcmp (type_str, 'triu')
    [r c] = deal (c,r);
 end

 return
end

Juan Pablo Carbajal <juanpi>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #24135:  ind2sub_tril.m added by juanpi (1KiB - text/x-objcsrc - Octave functions)
file #24136:  sub2ind_tril.m added by juanpi (1KiB - text/x-objcsrc - Octave functions)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jordigh (Updated the item)
  • -email is unavailable- added by juanpi (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-11-21 jordigh StatusNone Wont Do
        Open/ClosedOpen Closed
    2011-10-12 juanpi Attached File- Added ind2sub_tril.m, #24135
        Attached File- Added sub2ind_tril.m, #24136

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code