Sha256: 594e205b9ff35fb9d1d9c42c88eb5704b1dcf427305336923bd704fcad4c7180

Contents?: true

Size: 891 Bytes

Versions: 35

Compression:

Stored size: 891 Bytes

Contents

// Scilab ( http://www.scilab.org/ )
// Copyright (C) INRIA - Serge STEER
// 

function I=sub2ind(dims,varargin)
//sub2ind is used to determine the equivalent single index
//corresponding to a given set of subscript values.
 
//I = sub2ind(dims,i1,i2,..) returns the linear index equivalent to the
//row,  column, ... subscripts in the arrays i1,i2,..  for an matrix of
//size dims.
 
//I = sub2ind(dims,Mi) returns the linear index
//equivalent to the n subscripts in the columns of the matrix Mi for a matrix
//of size dims.
 
  d=[1;cumprod(matrix(dims(1:$-1),-1,1))]
  for i=1:size(varargin)
    if varargin(i)==[] then I=[],return,end
  end

  if size(varargin)==1 then //subindices are the columns of the argument
    I=(varargin(1)-1)*d+1
  else //subindices are given as separated arguments
    I=1
    for i=1:size(varargin)
      I=I+(varargin(i)-1)*d(i)
    end
  end
endfunction

Version data entries

35 entries across 35 versions & 5 rubygems

Version Path
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/pygments.rb-0.6.3/vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.6.3 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.6.2 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.6.1 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.6.0 vendor/pygments-main/tests/examplefiles/scilab.sci
mortar-pygments.rb-0.5.7 vendor/pygments-main/tests/examplefiles/scilab.sci
mortar-pygments.rb-0.5.6 vendor/pygments-main/tests/examplefiles/scilab.sci
mortar-pygments.rb-0.5.5 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-jruby-0.5.4.2 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-jruby-0.5.4.1 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-jruby-0.5.4 vendor/pygments-main/tests/examplefiles/scilab.sci
gitlab-pygments.rb-0.5.4 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.5.4 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.5.2 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.5.1 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.5.0 vendor/pygments-main/tests/examplefiles/scilab.sci
gitlab-pygments.rb-0.3.2 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.4.2 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.4.1 vendor/pygments-main/tests/examplefiles/scilab.sci
pygments.rb-0.3.7 vendor/pygments-main/tests/examplefiles/scilab.sci