text:
function []=plot_all_ifgs(type,n_x,textsize)
% PLOT_ALL_IFGS plot all interferograms
%
%   Andy Hooper, June 2006
%
%   ======================================================
%   09/2006 AH:  small baselines added
%   03/2007 AH:  variable text size added
%   04/2007 AH:  azimuth interferograms added
%   09/2008 AH:  generalise for other sensors
%   ======================================================

if nargin<1
    type=0;
end

if nargin<2
    n_x=0;
end

if nargin<3
    textsize=0;
end

heading=getparm('heading');
if isempty(heading)
   heading=-160;
end

if exist('looks.txt','file')
    looks=load('looks.txt');
else
    looks=4;
end

if type==0
    ifgfile=['cint.minrefdem_',num2str(looks),'l.ras'];
else
    ifgfile=['cint.azint_',num2str(looks),'l.ras'];
end

%y=linspace(0.80,0.05,5);
%x=linspace(0.05,0.85,6);
%[imY,imX]=meshgrid(y,x);
%lx=0.14;
%ly=0.135;
i2=0;
ifgstack=[];
ifgname=[];
ifgname2=[];

if strcmpi(getparm('insar_processor'),'gsar')
    pscname='pscphase.in';
    fid=fopen(pscname);
    ifgs=textscan(fid,'%s');
    fclose(fid);
    ifgs=ifgs{1}(2:end);
    for i=1:length(ifgs)
        ras=dir([ifgs{i},'.*l.ras']);
        splitras=strsplit(ras.name,'.');
        [ifg,cc]=imread([ifgs{i},'.',splitras{end-1},'.',splitras{end}]);
        ifgstack(:,:,i)=ifg;
        ifgname(i)=str2num(ifgs{i}(end-35:end-28));
    end
else
  aa=dir;
  for i=1:size(aa,1)
    if aa(i).isdir==1 && strncmp(aa(i).name,'.',1)~=1
        dirname=aa(i).name;
        %if ~strncmp(aa(i).name,'1992',4) & ~strncmp(aa(i).name,'1993',4)
        cd(aa(i).name)
        if exist(ifgfile,'file')
            i2=i2+1;
            [ifg,cc]=imread(ifgfile);
            ifgstack(:,:,i2)=ifg;
            ifgname(i2)=str2num(dirname(1:8));
            if length(dirname)==17
                ifgname2(i2)=str2num(dirname(10:17));
            end
        end
        cd ..
        %end
    end
  end
end

bb=dir('*crop.slc');
if ~isempty(bb)
   mastername=str2num(bb.name(1:8));
   master_ix=sum(mastername>ifgname)+1;
   ifgname=[ifgname(1:master_ix-1),mastername,ifgname(master_ix:end)];
   ifgstack=cat(3,ifgstack(:,:,1:master_ix-1),ones(size(ifgstack(:,:,1)))*113,ifgstack(:,:,master_ix:end));
else
    master_ix=0;
end

[n_i,n_j,n_k]=size(ifgstack);
fig_ar=1.33;
ar=n_j/n_i/fig_ar;
if n_x==0
    n_y=ceil(sqrt(n_k*ar)); % number of plots in y direction
    n_x=ceil(n_k/n_y);
else
    n_y=ceil(n_x*ar) % number of plots in y direction
end
%n_y=ceil(sqrt(n_k*ar)); % number of plots in y direction
%n_x=ceil(n_k/n_y);
d_y=1/n_y;
d_x=d_y*ar;
if d_x>1/n_x
   d_x=1/n_x;
   d_y=d_x/ar;
end

%%% FIX %%%%%%%
%d_y=1/3
%d_x=1/5
%%% END FIX %%%

h_y=0.95*d_y;
h_x=h_y*ar;

y=1-d_y:-0.99/n_y:0;
x=0:d_x:1-d_x;

[imY,imX]=meshgrid(y,x);

if textsize==0
    textsize=round(12*4/n_x);
    if textsize<8
        textsize=8;
    end
end
l_t=1/9*textsize/12; % text length
h_t=1/50*textsize/12; % text height
x_t=round((h_x-l_t)/h_x/2*n_j);
x_master=round((h_x-l_t*0.8)/h_x/2*n_j);
y_t=round(h_t*1.3/h_y*n_i);
y_master=round(h_t*6/h_y*n_i);
y_t2=round(h_t*2.5/h_y*n_i);

day=datenum(num2str(ifgname'),'yyyymmdd');
if ~isempty(ifgname2)
    day2=datenum(num2str(ifgname2'),'yyyymmdd');
end
figure
for i=1:n_k
    axes('position',[imX(i),imY(i),h_x,h_y])
    %subplot(6,5,i);
    if heading <90 & heading >-90
        image(flipud(ifgstack(:,:,i)));
    else
        image(fliplr(ifgstack(:,:,i)));
    end
    box on
    axis equal
    axis tight
    set(gca,'yticklabel',[])
    set(gca,'xticklabel',[])
    axis equal
    axis tight
    t=text(x_t,y_t,[datestr(day(i),'dd mmm yyyy')]);
    set(t,'fontweight','bold','color',[1 1 0.996],'fontsize',textsize)
    if exist('day2','var') & length(day2) >= i
        t=text(x_t,y_t2,[datestr(day2(i),'dd mmm yyyy')]);
        set(t,'fontweight','bold','color',[1 1 0.996],'fontsize',textsize)
    end
    if i==master_ix
        t=text(x_master,y_master,'MASTER');
        set(t,'fontweight','bold','color',[1 1 0.996],'fontsize',textsize)
    end

    %xx=text(0,size(ix,1)*1.15,datestr(day(i)));
    %set(xx,'fontsize',8)

end

colormap(cc)

author: dbekaert

repo: StaMPS

save_path: github-repos/MATLAB/dbekaert-StaMPS


text:
function F = in_fread_micromed(sFile, sfid, SamplesBounds, ChannelsRange)
% IN_FREAD_MICROMED:  Read a block of recordings from a Micromed TRC file
%
% USAGE:  F = in_fread_micromed(sFile, sfid, SamplesBounds=[], ChannelsRange=[])

% @=============================================================================
% This function is part of the Brainstorm software:
% https://neuroimage.usc.edu/brainstorm
%
% Copyright (c) University of Southern California & McGill University
% This software is distributed under the terms of the GNU General Public License
% as published by the Free Software Foundation. Further details on the GPLv3
% license can be found at http://www.gnu.org/copyleft/gpl.html.
%
% FOR RESEARCH PURPOSES ONLY. THE SOFTWARE IS PROVIDED "AS IS," AND THE
% UNIVERSITY OF SOUTHERN CALIFORNIA AND ITS COLLABORATORS DO NOT MAKE ANY
% WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
% MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, NOR DO THEY ASSUME ANY
% LIABILITY OR RESPONSIBILITY FOR THE USE OF THIS SOFTWARE.
%
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2017

% Parse inputs
if (nargin < 4) || isempty(ChannelsRange)
    ChannelsRange = [1, sFile.header.num_channels];
end
if (nargin < 3) || isempty(SamplesBounds)
    SamplesBounds = round(sFile.prop.times .* sFile.prop.sfreq);
end

% ===== COMPUTE OFFSETS =====
nChannels     = double(sFile.header.num_channels);
nReadTimes    = SamplesBounds(2) - SamplesBounds(1) + 1;
nReadChannels = double(ChannelsRange(2) - ChannelsRange(1) + 1);
% Data type
bytesPerVal = sFile.header.num_bytes;
switch bytesPerVal
    case 1, dataClass = 'uint8';
    case 2, dataClass = 'uint16';
    case 4, dataClass = 'uint32';
end

% Sample offset of the first block, for reduced files
if isfield(sFile.header, 'smp_offset') && ~isempty(sFile.header.smp_offset)
    smp_offset = sFile.header.smp_offset;
else
    smp_offset = 0;
end
% Time offset
offsetTime = round((SamplesBounds(1) - smp_offset) * nChannels * bytesPerVal);
% Channel offset at the beginning and end of each channel block
offsetChannelStart = round((ChannelsRange(1)-1) * bytesPerVal);
offsetChannelEnd   = (nChannels - ChannelsRange(2)) * bytesPerVal;
% Start reading at this point
offsetStart = sFile.header.data_offset + offsetTime + offsetChannelStart;
% Number of time samples to skip after each channel
offsetSkip = offsetChannelStart + offsetChannelEnd;

% ===== READ DATA BLOCK =====
% Position file at the beginning of the trial
fseek(sfid, offsetStart, 'bof');
% Read trial data
% => WARNING: CALL TO FREAD WITH SKIP=0 DOES NOT WORK PROPERLY
if (offsetSkip == 0)
    F = fread(sfid, [nReadChannels, nReadTimes], dataClass);
else
    precision = sprintf('%d*%s', nReadChannels, dataClass);
    F = fread(sfid, [nReadChannels, nReadTimes], precision, offsetSkip);
end
% Check that data block was fully read
if (numel(F) < nReadTimes * nReadChannels)
    % Error message
    disp(sprintf('BST> ERROR: File is truncated (%d values were read instead of %d)...', numel(F), nReadTimes * nReadChannels));
    % Pad with zeros
    Ftmp = zeros(nReadChannels, nReadTimes);
    Ftmp(1:numel(F)) = F(:);
    F = Ftmp;
end
% Apply offset and gains
chan = sFile.header.electrode(ChannelsRange(1):ChannelsRange(2));
F = bst_bsxfun(@minus, F, [chan.logicGround]');
F = bst_bsxfun(@times, F, ([chan.physicalMin]' - [chan.physicalMax]') ./ ([chan.logicMax]' - [chan.logicMin]' + 1) .* [chan.unit_gain]');

author: brainstorm-tools


text:
function check = discrete_check ( a, b )

%*****************************************************************************80
%
%% DISCRETE_CHECK checks the parameters of the Discrete CDF.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    09 October 2004
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer A, the number of probabilities assigned.
%
%    Input, real B(A), the relative probabilities of
%    outcomes 1 through A.  Each entry must be nonnegative.
%
%    Output, logical CHECK, is true if the parameters are legal.
%
  for j = 1 : a
    if ( b(j) < 0.0 )
      fprintf ( 1, '\n' );
      fprintf ( 1, 'DISCRETE_CHECK - Fatal error!\n' );
      fprintf ( 1, '  Negative probabilities not allowed.\n' );
      check = 0;
      return
    end
  end

  b_sum = sum ( b(1:a) );

  if ( b_sum == 0.0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'DISCRETE_CHECK - Fatal error!\n' );
    fprintf ( 1, '  Total probablity is zero.\n' );
    check = 0;
    return
  end

  check = 1;

  return
end

author: johannesgerer

repo: jburkardt-m


text:
%% Copyright (C) 2016, 2018-2019 Colin B. Macdonald
%% Copyright (C) 2016 Abhinav Tripathi
%% Copyright (C) 2021 Johannes Maria Frank
%% Copyright (C) 2022 Chris Gorman
%% Copyright (C) 2022 Alex Vong
%%
%% This file is part of OctSymPy.
%%
%% OctSymPy is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published
%% by the Free Software Foundation; either version 3 of the License,
%% or (at your option) any later version.
%%
%% This software is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty
%% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
%% the GNU General Public License for more details.
%%
%% You should have received a copy of the GNU General Public
%% License along with this software; see the file COPYING.
%% If not, see <http://www.gnu.org/licenses/>.

%% -*- texinfo -*-
%% @deftypefn  {Function File}  {[@var{A}, @var{info}] =} python_ipc_native (@dots{})
%% Private helper function for Python IPC.
%%
%% @var{A} is the resulting object, which might be an error code.
%%
%% @var{info} usually contains diagnostics to help with debugging
%% or error reporting.
%%
%% @code{@var{info}.prelines}: the number of lines of header code
%% before the command starts.
%%
%% @end deftypefn

function [A, info] = python_ipc_native(what, cmd, varargin)

  persistent show_msg
  persistent have_headers

  info.prelines = 0;

  if (strcmp(what, 'reset'))
    A = true;
    have_headers = [];
    return
  end

  if ~(strcmp(what, 'run'))
    error('unsupported command')
  end

  verbose = ~sympref('quiet');

  if (verbose && isempty(show_msg))
    assert_pythonic_and_sympy ()
    fprintf ('Symbolic pkg v%s: ', sympref ('version'))
  end

  newl = sprintf('\n');

  if isempty(have_headers)
    pyexec(strjoin({'import sys'
                    'import sympy'
                    'import mpmath'
                    'import sympy as sp'
                    'from sympy import __version__ as spver'
                    'from sympy import *'
                    'from sympy.logic.boolalg import Boolean, BooleanFunction'
                    'from sympy.core.relational import Relational'
                    '# temporary? for piecewise support'
                    'from sympy.functions.elementary.piecewise import ExprCondPair'
                    'from sympy.integrals.risch import NonElementaryIntegral'
                    'from sympy.matrices.expressions.matexpr import MatrixElement'
                    '# for hypergeometric'
                    'from sympy.functions.special.hyper import TupleArg'
                    '# for sets'
                    'from sympy.utilities.iterables import uniq'
                    'try:'
                    '    # quick fix for https://github.com/cbm755/octsympy/issues/1053'
                    '    # TODO: investigate the sym ctor in this case, likely a better fix in there'
                    '    from sympy.core.symbol import Str'
                    'except ImportError:'
                    '    pass'
                    'import copy'
                    'import struct'
                    'import codecs'
                    'try:'
                    '    from packaging.version import Version'
                    'except ImportError:'
		    '    try:'
		    '        from sympy.external.importtools import version_tuple as Version'
		    '    except ImportError:'
                    '        from distutils.version import LooseVersion'
                    '        def Version(v):'
                    '            return LooseVersion(v.replace(".dev", ""))'
                    'import itertools'
                    'import collections'
                    'from re import split'
                    '# patch pretty printer, issue #952'
                    'from sympy.printing.pretty.pretty import PrettyPrinter'
                    '_mypp = PrettyPrinter'
                    'def _my_rev_print(cls, f, **kwargs):'
                    '    g = f.func(*reversed(f.args), evaluate=False)'
                    '    return cls._print_Function(g, **kwargs)'
                    '_mypp._print_LambertW = lambda cls, f: _my_rev_print(cls, f, func_name="lambertw")'
                    '_mypp._print_sinc = lambda cls, f: cls._print_Function(f.func(f.args[0]/sp.pi, evaluate=False))'
                    'del _mypp'
                    'def dbout(l):'
                    '    # should be kept in sync with the same function'
                    '    # defined in inst/private/python_header.py'
                    '    sys.stderr.write("pydebug: " + str(l) + "\n")'
                  }, newl))
    have_headers = true;
  end

  if (verbose && isempty (show_msg))
    fprintf ('using Pythonic interface, SymPy v%s.\n', ...
             char (py.sympy.__version__))
    show_msg = true;
  end

  ins = store_vars_in_python(varargin);
  pyexec (strjoin (cmd, newl));
  outs = pycall ('_fcn', ins);
  A = check_and_convert(outs);
end

repo: octsympy


text:
function pass = test_constructor2( pref )
% Test the Chebfun2v constructor when performing simple arithmetic
% operations.

if ( nargin < 1 )
    pref = chebfunpref;
end

tol = 100*pref.cheb2Prefs.chebfun2eps;

% check the vectorize flag:
f1 = @(x,y) x.*y;
f2 = @(x,y) x*y;
H1 = chebfun2v(f1, f1);
H2 = chebfun2v(f2, f2, 'vectorize');
pass(1) = norm( H1 - H2 ) < tol;

f1 = @(x,y) x.*y;
f2 = @(x,y) x*y;
H1 = chebfun2v(f1, f1, [-2 3 -1 0]);
H2 = chebfun2v(f2, f2, 'vectorize', [-2 3 -1 0]);
pass(2) = norm( H1 - H2 ) < tol;

f1 = @(x,y) x.*y;
f2 = @(x,y) x*y;
H1 = chebfun2v(f1, f1, f1);
H2 = chebfun2v(f2, f2, f2, 'vectorize');
pass(3) = norm( H1 - H2 ) < tol;

f1 = @(x,y) x.*y;
f2 = @(x,y) x*y;
H1 = chebfun2v(f1, f1, f1, [-2 3 -1 0]);
H2 = chebfun2v(f2, f2, f2, 'vectorize', [-2 3 -1 0]);
pass(4) = norm( H1 - H2 ) < tol;

% Test the constructor with a surface example:
u = chebfun2(@(u,v) u, [0 2*pi -1 1]);
v = chebfun2(@(u,v) v, [0 2*pi -1 1]);
x = (1+0.5*v.*cos(u/2)).*cos(u);
y = (1+0.5*v.*cos(u/2)).*sin(u);
z = 0.5*v.*sin(u/2);
r = [x;y;z];
ru = diff(r,1,1);
rv = diff(r,1,2);
pass(5) = ( norm(ru'*rv,inf) < 10*tol );

V = [sin(5*u);cos(5*v);0];
pass(6) = (V.nComponents == 3);

end

author: chebfun

repo: chebfun

save_path: github-repos/MATLAB/chebfun-chebfun


text:
% Copyright (C) 2017-2018 Titus Cieslewski, RPG, University of Zurich,
%   Switzerland
%   You can contact the author at <titus at ifi dot uzh dot ch>
% Copyright (C) 2017-2018 Siddharth Choudhary, College of Computing,
%   Georgia Institute of Technology, Atlanta, GA, USA
% Copyright (C) 2017-2018 Davide Scaramuzza, RPG, University of Zurich,
%   Switzerland
%
% This file is part of dslam_open.
%
% dslam_open is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% dslam_open is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with dslam_open. If not, see <http://www.gnu.org/licenses/>.

function runSimulationAndSave(robot_vo_data, decentr_stream, ...
    dvpr_train_path, distributed_mapper_location, dpath, params, data_type)
%% Prepare empty decentralized state.
decentr_state = initDecentrState(robot_vo_data);
%% Assign netvlad cluster centers
% set dvpr_train_path to folder containing a bunch of features
decentr_state = assignClusterCenters(...
    decentr_state, dvpr_train_path, params);

%% Play!
figure(1);
tic;
netvlad_match_stats = zeros(numel(decentr_stream), 4);
data_increments = cell(numel(decentr_stream), 1);
accuracy_measurements = {};
opt_handle = initOptHandle(params.num_robots);
dgs_stats = {};
% Start ATE eval 5 seconds into the dataset to avoid meaningless aligns.
last_accur_eval = 5;
for step_i = 1:numel(decentr_stream)
%for step_i = 1:500
    real_time = toc
    if (real_time < decentr_stream{step_i}.time)
        pause(decentr_stream{step_i}.time - real_time);
    end
    [decentr_state, data_increments{step_i}, ...
        netvlad_match_stats(step_i, :), opt_handle, dgs_stats_i] = ...
        stepDecentrState(decentr_state, decentr_stream{step_i}, params, ...
        distributed_mapper_location, opt_handle);
    dgs_stats = [dgs_stats; dgs_stats_i];

    if (mod(step_i, params.num_robots) == 0)
        plotDecentrState(decentr_state);
        pause(0.0001);
    end

    if ((decentr_stream{step_i}.time - last_accur_eval) > 1)
        last_accur_eval = decentr_stream{step_i}.time;
        [accuracy_measurement, decentr_state] = ...
            evalAccuracy(decentr_state, opt_handle, ...
            decentr_stream{step_i}.time);
        accuracy_measurements = [accuracy_measurements; ...
            accuracy_measurement];
    end
    disp([num2str(step_i) ' out of ' num2str(numel(decentr_stream))]);
end
data_increment_times = cellfun(@(x) x.time, decentr_stream);
% Wrap optimization, unless optimization is nop.
vo_end_state = decentr_state;
[decentr_state, dgs_stats_i, final_increments, ...
    final_increment_times, opt_handle, final_accuracy_measurements] = ...
    wrapUpOptimization(...
    decentr_state, opt_handle, ...
    distributed_mapper_location, params, decentr_stream{end}.time);

dgs_stats = [dgs_stats; dgs_stats_i];
data_increments = [data_increments; final_increments];
data_increment_times = [data_increment_times; final_increment_times];
accuracy_measurements = [...
    accuracy_measurements; final_accuracy_measurements];
plotDecentrState(decentr_state);
%% Save stats
%dlmwrite(...
%    [dpath 'netvlad_match_stats_' ...
%    num2str(cell2mat(struct2cell(params))') '.txt'], ...
%    netvlad_match_stats, ' ');
if strcmp(data_type, 'stata')
    save(...
        regexprep([dpath 'run_data_' ...
        num2str(cell2mat(struct2cell(params))') '.mat'], '\s+', ' '), ...
        'decentr_state', 'data_increments', 'data_increment_times', ...
        'accuracy_measurements', 'dgs_stats', 'vo_end_state', '-v7.3');
else
    save(...
        [dpath 'run_data_' ...
        num2str(cell2mat(struct2cell(params))') '.mat'], ...
        'decentr_state', 'data_increments', 'data_increment_times', ...
        'accuracy_measurements', 'dgs_stats', '-v7.3');

end

author: uzh-rpg


text:
classdef TestHfsSegment
    %TestHfsSegment

    methods (Static)
        function test_1
            img = cv.imread(fullfile(mexopencv.root(),'test','fruits.jpg'), ...
                'Color',true, 'ReduceScale',2);
            sz = size(img);
            hfs = cv.HfsSegment(sz(1), sz(2));

            res = hfs.performSegment(img, 'Draw',true);
            validateattributes(res, {class(img)}, {'size',sz});

            seg = hfs.performSegment(img, 'Draw',false);
            validateattributes(seg, {'uint16'}, {'size',sz(1:2)});
        end
    end

end

author: kyamagu

repo: mexopencv

save_path: github-repos/MATLAB/kyamagu-mexopencv


text:
function display(w)
   %DISPLAY Waveform Display overloaded operator

   % VERSION: 1.0 of waveform objects
   % AUTHOR: Celso Reyes (celso@gi.alaska.edu)
   % LASTUPDATE: 2/6/2007

   if isequal(get(0,'FormatSpacing'),'compact')
      disp([inputname(1) ' =']);
      disp(w);
   else
      disp(' ');
      disp([inputname(1) ' =']);
      disp(' ');
      disp(w);
   end
end

author: geoscience-community-codes

repo: GISMO


text:
function y = istrue(x)

% ISTRUE ensures that a true/false input argument like "yes", "true"
% or "on" is converted into a boolean

% Copyright (C) 2009, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.ru.nl/neuroimaging/fieldtrip
% for the documentation and details.
%
%    FieldTrip is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    FieldTrip is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
%
% $Id: istrue.m 2885 2011-02-16 09:41:58Z roboos $

true_list  = {'yes' 'true' 'on' 'y' };
false_list = {'no' 'false' 'off' 'n' 'none'};

if ischar(x)
  % convert string to boolean value
  if any(strcmpi(x, true_list))
    y = true;
  elseif any(strcmpi(x, false_list))
    y = false;
  else
    error('cannot determine whether "%s" should be interpreted as true or false', x);
  end
else
  % convert numerical value to boolean
  y = logical(x);
end

author: PatternRecognition

repo: OpenBMI


text:
function mono_next_grlex_test ( )

%*****************************************************************************80
%
%% MONO_NEXT_GRLEX_TEST tests MONO_NEXT_GRLEX.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    05 February 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'MONO_NEXT_GRLEX_TEST\n' );
  fprintf ( 1, '  MONO_NEXT_GRLEX returns the next monomial\n' );
  fprintf ( 1, '  in graded lexicographic order.\n' );

  m = 4;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Let M =  %d\n', m );

  k = 0;
  x = zeros ( m, 1 );

  while ( 1 )

    d = sum ( x(1:m) );
    fprintf ( 1, '  %2d  %2d  |  %2d  %2d  %2d  %2d\n', k, d, x(1:m) );
    if ( x(1) == 3 )
      break
    end
    k = k + 1;
    x = mono_next_grlex ( m, x );
  end

  return
end


text:
function gitInfo=getGitInfo()
% Matlab script to get information about the Git repository in the current directory, including:
%          - branch name of the current Git Repo
%          -Git SHA1 HASH of the most recent commit
%          -url of corresponding remote repository, if one exists
%
% The function first checks to see if a .git/ directory is present. If so it
% reads the .git/HEAD file to identify the branch name and then it looks up
% the corresponding commit.
%
% It then reads the .git/config file to find out the url of the
% corresponding remote repository. This is all stored in a gitInfo struct.
%
% Note this uses only file information, it makes no external program
% calls at all.
%
% This function must be in the base directory of the git repository
%
% Released under a BSD open source license. Based on a concept by Marc
% Gershow.
%
% Andrew Leifer
% Harvard University
% Program in Biophysics, Center for Brain Science,
% and Department of Physics
% leifer@fas.harvard.edu
% http://www.andrewleifer.com
% 12 September 2011
%
%
%

% Copyright 2011 Andrew Leifer. All rights reserved.
%
% Redistribution and use in source and binary forms, with or without modification, are
% permitted provided that the following conditions are met:
%
%    1. Redistributions of source code must retain the above copyright notice, this list of
%       conditions and the following disclaimer.
%
%    2. Redistributions in binary form must reproduce the above copyright notice, this list
%       of conditions and the following disclaimer in the documentation and/or other materials
%       provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
% FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
% SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
% ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
% The views and conclusions contained in the software and documentation are those of the
% authors and should not be interpreted as representing official policies, either expressed
% or implied, of <copyright holder>.

gitpath = mtex_path;

 gitInfo=[];
if ~exist(fullfile(gitpath,'.git'),'file') || ~exist(fullfile(gitpath,'.git','HEAD'),'file')
    %Git is not present
    return
end

%Read in the HEAD information, this will tell us the location of the file
%containing the SHA1
text=fileread(fullfile(gitpath,'.git','HEAD'));
parsed=textscan(text,'%s');

if ~strcmp(parsed{1}{1},'ref:') || ~length(parsed{1})>1
        %the HEAD is not in the expected format.
        %give up
        return
end

path=parsed{1}{2};
[pathstr, name, ext]=fileparts(path);
branchName=name;

%save branchname
gitInfo.branch=branchName;

%Read in SHA1
SHA1text=fileread(fullfile(gitpath,'.git', pathstr,[name ext]));
SHA1=textscan(SHA1text,'%s');
gitInfo.hash=SHA1{1}{1};

%Read in config file
config=fileread(fullfile(gitpath,'.git/config'));
%Find everything space delimited
temp=textscan(config,'%s','delimiter','\n');
lines=temp{1};

remote='';
%Lets find the name of the remote corresponding to our branchName
for k=1:length(lines)

    %Are we at the section describing our branch?
    if strcmp(lines{k},['[branch "' branchName '"]'])
        m=k+1;
        %While we haven't run out of lines
        %And while we haven't run into another section (which starts with
        % an open bracket)
        while (m<=length(lines) && ~strcmp(lines{m}(1),'[') )
            temp=textscan(lines{m},'%s');
            if length(temp{1})>=3
                if strcmp(temp{1}{1},'remote') && strcmp(temp{1}{2},'=')
                    %This is the line that tells us the name of the remote
                    remote=temp{1}{3};
                end
            end

            m=m+1;
        end

    end
end
gitInfo.remote=remote;

url='';
%Find the remote's url
for k=1:length(lines)

    %Are we at the section describing our branch?
    if strcmp(lines{k},['[remote "' remote '"]'])
        m=k+1;
        %While we haven't run out of lines
        %And while we haven't run into another section (which starts with
        % an open bracket)
        while (m<=length(lines) && ~strcmp(lines{m}(1),'[') )
            temp=textscan(lines{m},'%s');
            if length(temp{1})>=3
                if strcmp(temp{1}{1},'url') && strcmp(temp{1}{2},'=')
                    %This is the line that tells us the name of the remote
                    url=temp{1}{3};
                end
            end

            m=m+1;
        end

    end
end

gitInfo.url=url;

author: mtex-toolbox

repo: mtex

save_path: github-repos/MATLAB/mtex-toolbox-mtex


text:
function vr = rotateVector(v, angle)
%ROTATEVECTOR Rotate a vector by a given angle.
%
%   VR = rotateVector(V, THETA)
%   Rotate the vector V by an angle THETA, given in radians.
%
%   Example
%   rotateVector([1 0], pi/2)
%   ans =
%       0   1
%
%   See also
%   vectors2d, transformVector, createRotation
%
% ------
% Author: David Legland
% e-mail: david.legland@grignon.inra.fr
% Created: 2011-04-14,    using Matlab 7.9.0.529 (R2009b)
% Copyright 2011 INRA - Cepia Software Platform.

% precomputes angles
cot = cos(angle);
sit = sin(angle);

% compute rotated coordinates
vr = [cot * v(:,1) - sit * v(:,2) , sit * v(:,1) + cot * v(:,2)];

author: Arrowstar

repo: ksptot

save_path: github-repos/MATLAB/Arrowstar-ksptot