text:
function [ f, rank ] = rgf_successor ( m, f, rank )

%*****************************************************************************80
%
%% RGF_SUCCESSOR generates the next restricted growth function.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    26 January 2011
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Donald Kreher, Douglas Simpson,
%    Combinatorial Algorithms,
%    CRC Press, 1998,
%    ISBN: 0-8493-3988-X,
%    LC: QA164.K73.
%
%  Parameters:
%
%    Input, integer M, the domain of the RGF is the integers
%    from 1 to M.  M must be positive.
%
%    Input/output, integer F(M), the restricted growth function.
%
%    Input/output, integer RANK, the rank.
%    If RANK = -1 on input, then the routine understands that this is
%    the first call, and that the user wishes the routine to supply
%    the first element in the ordering, which has RANK = 0.
%    In general, the input value of RANK is increased by 1 for output,
%    unless the very last element of the ordering was input, in which
%    case the output value of RANK is 0.
%

%
%  Return the first element.
%
  if ( rank == -1 )
    f(1:m) = 1;
    rank = 0;
    return
  end
%
%  Check.
%
  ierror = rgf_check ( m, f );

  if ( ierror ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'RGF_SUCCESSOR - Fatal error!\n' );
    fprintf ( 1, '  The input array is illegal!\n' );
    fprintf ( 1, '  IERROR = %d\n', ierror );
    error ( 'RGF_SUCCESSOR - Fatal error!\n' );
  end
%
%  Find the first position from the right which can be incremented.
%
  for i = m : -1 : 2

    fmax = 1;
    for j = 2 : i - 1
      fmax = max ( fmax, f(j) );
    end
%
%  Increment the function at this position, and set later entries to 1.
%
    if ( f(i) ~= fmax + 1 )
      f(i) = f(i) + 1;
      f(i+1:m) = 1;
      rank = rank + 1;
      return
    end

  end
%
%  The final element was input.
%  Return the first element.
%
  f(1:m) = 1;
  rank = 0;

  return
end

author: johannesgerer

repo: jburkardt-m


text:
function gridcosts(ch,k,K,x,~)
if k==K
  ch.add(x.time);
end

author: OpenOCL

repo: OpenOCL

save_path: github-repos/MATLAB/OpenOCL-OpenOCL


text:
function [ a2, b2 ] = i4vec2_sorted_uniquely ( n1, a1, b1, n2 )

%*****************************************************************************80
%
%% I4VEC2_SORTED_UNIQUELY copies unique elements from a sorted I4VEC2.
%
%  Discussion:
%
%    An I4VEC2 is a pair of I4VEC's.
%
%    An I4VEC is a vector of I4's.
%
%    Entry K of an I4VEC2 is the pair of values located
%    at the K-th entries of the two I4VEC's.
%
%    Item I is stored as the pair A1(I), A2(I).
%
%    The items must have been sorted, or at least it must be the
%    case that equal items are stored in adjacent vector locations.
%
%    If the items were not sorted, then this routine will only
%    replace a string of equal values by a single representative.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    14 July 2014
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N1, the number of items.
%
%    Input, integer A1(N1), B1(N1), the array of items.
%
%    Input, integer N2, the number of unique items.
%
%    Output, integer A2(N2), B2(N2), the array of unique items.
%
  a2 = zeros(n2,1);
  b2 = zeros(n2,1);

  i1 = 1;
  i2 = 1;
  a2(i2) = a1(i1);
  b2(i2) = b1(i1);

  for i1 = 2 : n1

    if ( a1(i1) ~= a2(i2) || b1(i1) ~= b2(i2) )

      i2 = i2 + 1;

      a2(i2) = a1(i1);
      b2(i2) = b1(i1);

    end

  end

  return
end


text:
classdef ProductComputer < handle

    properties (Access = protected)
        secondOrder
        fourthOrder
        secondOrderOut
    end

    methods (Access = public, Static)

        function s = compute(C,e)
            factory = ProductComputerFactory();
            productComputer = factory.create(C,e);
            s = productComputer.getOutputSecondOrder();
        end

    end

    methods (Access = protected)

        function generate(obj,C,e)
            obj.init(C,e)
            obj.createOutSecondOrder()
            obj.computeProduct()
        end

    end

    methods (Access = private)

        function init(obj,C,e)
            obj.fourthOrder = C;
            obj.secondOrder = e;
        end

        function createOutSecondOrder(obj)
            C = obj.fourthOrder;
            e = obj.secondOrder;
            outCreator = ProductComputerOutputCreator(C,e);
            obj.secondOrderOut = outCreator.getSecondOrderOut;
        end

        function s = getOutputSecondOrder(obj)
            s = obj.secondOrderOut;
        end
    end

    methods (Access = protected, Abstract)
        computeProduct(obj)
    end

end

author: SwanLab

repo: Swan

save_path: github-repos/MATLAB/SwanLab-Swan