text:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                                                                  %%%%%
%%%%    IEEE PES Power Grid Library - Optimal Power Flow - v21.07     %%%%%
%%%%          (https://github.com/power-grid-lib/pglib-opf)           %%%%%
%%%%             Benchmark Group - Active Power Increase              %%%%%
%%%%                         29 - July - 2021                         %%%%%
%%%%                                                                  %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function mpc = pglib_opf_case24_ieee_rts__api
mpc.version = '2';
mpc.baseMVA = 100.0;

%% area data
%	area	refbus
mpc.areas = [
	1	 1;
	2	 3;
	3	 8;
	4	 6;
];

%% bus data
%	bus_i	type	Pd	Qd	Gs	Bs	area	Vm	Va	baseKV	zone	Vmax	Vmin
mpc.bus = [
	1	 2	 207.30	 22.00	 0.0	 0.0	 1	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	2	 2	 186.19	 20.00	 0.0	 0.0	 1	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	3	 1	 345.50	 37.00	 0.0	 0.0	 1	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	4	 1	 142.04	 15.00	 0.0	 0.0	 1	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	5	 1	 136.28	 14.00	 0.0	 0.0	 1	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	6	 1	 261.04	 28.00	 0.0	 -100.0	 2	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	7	 2	 239.93	 25.00	 0.0	 0.0	 2	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	8	 1	 328.23	 35.00	 0.0	 0.0	 2	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	9	 1	 335.90	 36.00	 0.0	 0.0	 1	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	10	 1	 374.29	 40.00	 0.0	 0.0	 2	    1.00000	    0.00000	 138.0	 1	    1.05000	    0.95000;
	11	 1	 0.0	 0.0	 0.0	 0.0	 3	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	12	 1	 0.0	 0.0	 0.0	 0.0	 3	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	13	 3	 508.65	 54.00	 0.0	 0.0	 3	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	14	 2	 372.37	 39.00	 0.0	 0.0	 3	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	15	 2	 608.47	 64.00	 0.0	 0.0	 4	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	16	 2	 191.94	 20.00	 0.0	 0.0	 4	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	17	 1	 0.0	 0.0	 0.0	 0.0	 4	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	18	 2	 639.18	 68.00	 0.0	 0.0	 4	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	19	 1	 347.42	 37.00	 0.0	 0.0	 3	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	20	 1	 245.69	 26.00	 0.0	 0.0	 3	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	21	 2	 0.0	 0.0	 0.0	 0.0	 4	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	22	 2	 0.0	 0.0	 0.0	 0.0	 4	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	23	 2	 0.0	 0.0	 0.0	 0.0	 3	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
	24	 1	 0.0	 0.0	 0.0	 0.0	 4	    1.00000	    0.00000	 230.0	 1	    1.05000	    0.95000;
];

%% generator data
%	bus	Pg	Qg	Qmax	Qmin	Vg	mBase	status	Pmax	Pmin
mpc.gen = [
	1	 43.5	 0.0	 40.0	 -40.0	 1.0	 100.0	 1	 79	 8.0; % PEL
	1	 109.5	 0.0	 106.0	 -106.0	 1.0	 100.0	 1	 211	 8.0; % PEL
	1	 41.3	 0.0	 38.0	 -38.0	 1.0	 100.0	 1	 75	 7.6; % PEL
	1	 42.8	 0.0	 39.0	 -39.0	 1.0	 100.0	 1	 78	 7.6; % NG
	2	 98.0	 0.0	 94.0	 -94.0	 1.0	 100.0	 1	 188	 8.0; % NG
	2	 95.0	 0.0	 91.0	 -91.0	 1.0	 100.0	 1	 182	 8.0; % PEL
	2	 91.8	 0.0	 88.0	 -88.0	 1.0	 100.0	 1	 176	 7.6; % NG
	2	 335.3	 0.0	 332.0	 -332.0	 1.0	 100.0	 1	 663	 7.6; % COW
	7	 221.25	 0.0	 215.0	 -215.0	 1.0	 100.0	 1	 430	 12.5; % NG
	7	 82.75	 0.0	 77.0	 -77.0	 1.0	 100.0	 1	 153	 12.5; % NG
	7	 303.75	 0.0	 298.0	 -298.0	 1.0	 100.0	 1	 595	 12.5; % COW
	13	 289.25	 0.0	 272.0	 -272.0	 1.0	 100.0	 1	 544	 34.5; % NG
	13	 288.25	 0.0	 271.0	 -271.0	 1.0	 100.0	 1	 542	 34.5; % NG
	13	 321.75	 0.0	 305.0	 -305.0	 1.0	 100.0	 1	 609	 34.5; % COW
	14	 0.0	 0.0	 252.0	 -252.0	 1.0	 100.0	 1	 0	 0.0; % SYNC
	15	 80.1	 0.0	 94.8	 -94.8	 1.0	 100.0	 1	 159	 1.2; % NG
	15	 103.6	 0.0	 103.0	 -103.0	 1.0	 100.0	 1	 206	 1.2; % COW
	15	 98.1	 0.0	 98.0	 -98.0	 1.0	 100.0	 1	 195	 1.2; % NG
	15	 81.6	 0.0	 94.8	 -94.8	 1.0	 100.0	 1	 162	 1.2; % NG
	15	 70.1	 0.0	 94.8	 -94.8	 1.0	 100.0	 1	 139	 1.2; % NG
	15	 116.575	 0.0	 103.0	 -103.0	 1.0	 100.0	 1	 206	 27.15; % NG
	16	 308.075	 0.0	 295.0	 -295.0	 1.0	 100.0	 1	 589	 27.15; % NG
	18	 216.0	 4.5	 200.0	 -191.0	 1.0	 100.0	 1	 382	 50.0; % NG
	21	 362.5	 0.0	 338.0	 -338.0	 1.0	 100.0	 1	 675	 50.0; % COW
	22	 113.5	 0.0	 111.0	 -111.0	 1.0	 100.0	 1	 222	 5.0; % NG
	22	 94.5	 0.0	 92.0	 -92.0	 1.0	 100.0	 1	 184	 5.0; % NG
	22	 75.5	 0.0	 73.0	 -73.0	 1.0	 100.0	 1	 146	 5.0; % NG
	22	 119.0	 0.0	 117.0	 -117.0	 1.0	 100.0	 1	 233	 5.0; % COW
	22	 110.5	 0.0	 108.0	 -108.0	 1.0	 100.0	 1	 216	 5.0; % NG
	22	 44.0	 0.0	 42.0	 -42.0	 1.0	 100.0	 1	 83	 5.0; % NG
	23	 224.075	 0.0	 211.0	 -211.0	 1.0	 100.0	 1	 421	 27.15; % NG
	23	 159.575	 0.0	 146.0	 -146.0	 1.0	 100.0	 1	 292	 27.15; % COW
	23	 226.0	 0.0	 191.0	 -191.0	 1.0	 100.0	 1	 382	 70.0; % NG
];

%% generator cost data
%	2	startup	shutdown	n	c(n-1)	...	c0
mpc.gencost = [
	2	 1500.0	 0.0	 3	   0.000000	 130.000000	 400.684900; % PEL
	2	 1500.0	 0.0	 3	   0.000000	 130.000000	 400.684900; % PEL
	2	 1500.0	 0.0	 3	   0.014142	  16.081100	 212.307600; % PEL
	2	 1500.0	 0.0	 3	   0.014142	  16.081100	 212.307600; % NG
	2	 1500.0	 0.0	 3	   0.000000	 130.000000	 400.684900; % NG
	2	 1500.0	 0.0	 3	   0.000000	 130.000000	 400.684900; % PEL
	2	 1500.0	 0.0	 3	   0.014142	  16.081100	 212.307600; % NG
	2	 1500.0	 0.0	 3	   0.014142	  16.081100	 212.307600; % COW
	2	 1500.0	 0.0	 3	   0.052672	  43.661500	 781.521000; % NG
	2	 1500.0	 0.0	 3	   0.052672	  43.661500	 781.521000; % NG
	2	 1500.0	 0.0	 3	   0.052672	  43.661500	 781.521000; % COW
	2	 1500.0	 0.0	 3	   0.007170	  48.580400	 832.757500; % NG
	2	 1500.0	 0.0	 3	   0.007170	  48.580400	 832.757500; % NG
	2	 1500.0	 0.0	 3	   0.007170	  48.580400	 832.757500; % COW
	2	 1500.0	 0.0	 3	   0.000000	   0.000000	   0.000000; % SYNC
	2	 1500.0	 0.0	 3	   0.328412	  56.564000	  86.385200; % NG
	2	 1500.0	 0.0	 3	   0.328412	  56.564000	  86.385200; % COW
	2	 1500.0	 0.0	 3	   0.328412	  56.564000	  86.385200; % NG
	2	 1500.0	 0.0	 3	   0.328412	  56.564000	  86.385200; % NG
	2	 1500.0	 0.0	 3	   0.328412	  56.564000	  86.385200; % NG
	2	 1500.0	 0.0	 3	   0.008342	  12.388300	 382.239100; % NG
	2	 1500.0	 0.0	 3	   0.008342	  12.388300	 382.239100; % NG
	2	 1500.0	 0.0	 3	   0.000213	   4.423100	 395.374900; % NG
	2	 1500.0	 0.0	 3	   0.000213	   4.423100	 395.374900; % COW
	2	 1500.0	 0.0	 3	   0.000000	   0.001000	   0.001000; % NG
	2	 1500.0	 0.0	 3	   0.000000	   0.001000	   0.001000; % NG
	2	 1500.0	 0.0	 3	   0.000000	   0.001000	   0.001000; % NG
	2	 1500.0	 0.0	 3	   0.000000	   0.001000	   0.001000; % COW
	2	 1500.0	 0.0	 3	   0.000000	   0.001000	   0.001000; % NG
	2	 1500.0	 0.0	 3	   0.000000	   0.001000	   0.001000; % NG
	2	 1500.0	 0.0	 3	   0.008342	  12.388300	 382.239100; % NG
	2	 1500.0	 0.0	 3	   0.008342	  12.388300	 382.239100; % COW
	2	 1500.0	 0.0	 3	   0.004895	  11.849500	 665.109400; % NG
];

%% branch data
%	fbus	tbus	r	x	b	rateA	rateB	rateC	ratio	angle	status	angmin	angmax
mpc.branch = [
	1	 2	 0.0026	 0.0139	 0.4611	 175.0	 193.0	 200.0	 0.0	 0.0	 1	 -30.0	 30.0;
	1	 3	 0.0546	 0.2112	 0.0572	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	1	 5	 0.0218	 0.0845	 0.0229	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	2	 4	 0.0328	 0.1267	 0.0343	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	2	 6	 0.0497	 0.192	 0.052	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	3	 9	 0.0308	 0.119	 0.0322	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	3	 24	 0.0023	 0.0839	 0.0	 400.0	 510.0	 600.0	 1.03	 0.0	 1	 -30.0	 30.0;
	4	 9	 0.0268	 0.1037	 0.0281	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	5	 10	 0.0228	 0.0883	 0.0239	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	6	 10	 0.0139	 0.0605	 2.459	 175.0	 193.0	 200.0	 0.0	 0.0	 1	 -30.0	 30.0;
	7	 8	 0.0159	 0.0614	 0.0166	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	8	 9	 0.0427	 0.1651	 0.0447	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	8	 10	 0.0427	 0.1651	 0.0447	 175.0	 208.0	 220.0	 0.0	 0.0	 1	 -30.0	 30.0;
	9	 11	 0.0023	 0.0839	 0.0	 400.0	 510.0	 600.0	 1.03	 0.0	 1	 -30.0	 30.0;
	9	 12	 0.0023	 0.0839	 0.0	 400.0	 510.0	 600.0	 1.03	 0.0	 1	 -30.0	 30.0;
	10	 11	 0.0023	 0.0839	 0.0	 400.0	 510.0	 600.0	 1.02	 0.0	 1	 -30.0	 30.0;
	10	 12	 0.0023	 0.0839	 0.0	 400.0	 510.0	 600.0	 1.02	 0.0	 1	 -30.0	 30.0;
	11	 13	 0.0061	 0.0476	 0.0999	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	11	 14	 0.0054	 0.0418	 0.0879	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	12	 13	 0.0061	 0.0476	 0.0999	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	12	 23	 0.0124	 0.0966	 0.203	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	13	 23	 0.0111	 0.0865	 0.1818	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	14	 16	 0.005	 0.0389	 0.0818	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	15	 16	 0.0022	 0.0173	 0.0364	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	15	 21	 0.0063	 0.049	 0.103	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	15	 21	 0.0063	 0.049	 0.103	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	15	 24	 0.0067	 0.0519	 0.1091	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	16	 17	 0.0033	 0.0259	 0.0545	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	16	 19	 0.003	 0.0231	 0.0485	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	17	 18	 0.0018	 0.0144	 0.0303	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	17	 22	 0.0135	 0.1053	 0.2212	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	18	 21	 0.0033	 0.0259	 0.0545	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	18	 21	 0.0033	 0.0259	 0.0545	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	19	 20	 0.0051	 0.0396	 0.0833	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	19	 20	 0.0051	 0.0396	 0.0833	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	20	 23	 0.0028	 0.0216	 0.0455	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	20	 23	 0.0028	 0.0216	 0.0455	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
	21	 22	 0.0087	 0.0678	 0.1424	 500.0	 600.0	 625.0	 0.0	 0.0	 1	 -30.0	 30.0;
];

% INFO    : === Translation Options ===
% INFO    : Load Model:                  from file ./pglib_opf_case24_ieee_rts.m.api.sol
% INFO    : Gen Active Capacity Model:   stat
% INFO    : Gen Reactive Capacity Model: al50ag
% INFO    : Gen Active Cost Model:       stat
% INFO    :
% INFO    : === Load Replacement Notes ===
% INFO    : Bus 1	: Pd=108.0, Qd=22.0 -> Pd=207.30, Qd=22.00
% INFO    : Bus 2	: Pd=97.0, Qd=20.0 -> Pd=186.19, Qd=20.00
% INFO    : Bus 3	: Pd=180.0, Qd=37.0 -> Pd=345.50, Qd=37.00
% INFO    : Bus 4	: Pd=74.0, Qd=15.0 -> Pd=142.04, Qd=15.00
% INFO    : Bus 5	: Pd=71.0, Qd=14.0 -> Pd=136.28, Qd=14.00
% INFO    : Bus 6	: Pd=136.0, Qd=28.0 -> Pd=261.04, Qd=28.00
% INFO    : Bus 7	: Pd=125.0, Qd=25.0 -> Pd=239.93, Qd=25.00
% INFO    : Bus 8	: Pd=171.0, Qd=35.0 -> Pd=328.23, Qd=35.00
% INFO    : Bus 9	: Pd=175.0, Qd=36.0 -> Pd=335.90, Qd=36.00
% INFO    : Bus 10	: Pd=195.0, Qd=40.0 -> Pd=374.29, Qd=40.00
% INFO    : Bus 13	: Pd=265.0, Qd=54.0 -> Pd=508.65, Qd=54.00
% INFO    : Bus 14	: Pd=194.0, Qd=39.0 -> Pd=372.37, Qd=39.00
% INFO    : Bus 15	: Pd=317.0, Qd=64.0 -> Pd=608.47, Qd=64.00
% INFO    : Bus 16	: Pd=100.0, Qd=20.0 -> Pd=191.94, Qd=20.00
% INFO    : Bus 18	: Pd=333.0, Qd=68.0 -> Pd=639.18, Qd=68.00
% INFO    : Bus 19	: Pd=181.0, Qd=37.0 -> Pd=347.42, Qd=37.00
% INFO    : Bus 20	: Pd=128.0, Qd=26.0 -> Pd=245.69, Qd=26.00
% INFO    :
% INFO    : === Generator Setpoint Replacement Notes ===
% INFO    : Gen at bus 1	: Pg=18.0, Qg=5.0 -> Pg=73.0, Qg=1.0
% INFO    : Gen at bus 1	: Pg=18.0, Qg=5.0 -> Pg=73.0, Qg=1.0
% INFO    : Gen at bus 1	: Pg=45.6, Qg=2.5 -> Pg=72.0, Qg=1.0
% INFO    : Gen at bus 1	: Pg=45.6, Qg=2.5 -> Pg=72.0, Qg=1.0
% INFO    : Gen at bus 2	: Pg=18.0, Qg=5.0 -> Pg=157.0, Qg=31.0
% INFO    : Gen at bus 2	: Pg=18.0, Qg=5.0 -> Pg=157.0, Qg=31.0
% INFO    : Gen at bus 2	: Pg=45.6, Qg=2.5 -> Pg=156.0, Qg=31.0
% INFO    : Gen at bus 2	: Pg=45.6, Qg=2.5 -> Pg=156.0, Qg=31.0
% INFO    : Gen at bus 7	: Pg=62.5, Qg=30.0 -> Pg=126.0, Qg=42.0
% INFO    : Gen at bus 7	: Pg=62.5, Qg=30.0 -> Pg=126.0, Qg=42.0
% INFO    : Gen at bus 7	: Pg=62.5, Qg=30.0 -> Pg=126.0, Qg=42.0
% INFO    : Gen at bus 13	: Pg=133.0, Qg=40.0 -> Pg=410.0, Qg=105.0
% INFO    : Gen at bus 13	: Pg=133.0, Qg=40.0 -> Pg=410.0, Qg=105.0
% INFO    : Gen at bus 13	: Pg=133.0, Qg=40.0 -> Pg=410.0, Qg=105.0
% INFO    : Gen at bus 14	: Pg=0.0, Qg=75.0 -> Pg=0.0, Qg=210.0
% INFO    : Gen at bus 15	: Pg=7.2, Qg=3.0 -> Pg=132.0, Qg=79.0
% INFO    : Gen at bus 15	: Pg=7.2, Qg=3.0 -> Pg=132.0, Qg=79.0
% INFO    : Gen at bus 15	: Pg=7.2, Qg=3.0 -> Pg=132.0, Qg=79.0
% INFO    : Gen at bus 15	: Pg=7.2, Qg=3.0 -> Pg=132.0, Qg=79.0
% INFO    : Gen at bus 15	: Pg=7.2, Qg=3.0 -> Pg=132.0, Qg=79.0
% INFO    : Gen at bus 15	: Pg=104.65, Qg=15.0 -> Pg=184.0, Qg=79.0
% INFO    : Gen at bus 16	: Pg=104.65, Qg=15.0 -> Pg=522.0, Qg=-34.0
% INFO    : Gen at bus 18	: Pg=250.0, Qg=75.0 -> Pg=301.0, Qg=32.0
% INFO    : Gen at bus 21	: Pg=250.0, Qg=75.0 -> Pg=203.0, Qg=-118.0
% INFO    : Gen at bus 22	: Pg=30.0, Qg=3.0 -> Pg=68.0, Qg=-9.0
% INFO    : Gen at bus 22	: Pg=30.0, Qg=3.0 -> Pg=68.0, Qg=-9.0
% INFO    : Gen at bus 22	: Pg=30.0, Qg=3.0 -> Pg=68.0, Qg=-9.0
% INFO    : Gen at bus 22	: Pg=30.0, Qg=3.0 -> Pg=68.0, Qg=-9.0
% INFO    : Gen at bus 22	: Pg=30.0, Qg=3.0 -> Pg=68.0, Qg=-9.0
% INFO    : Gen at bus 22	: Pg=30.0, Qg=3.0 -> Pg=68.0, Qg=-9.0
% INFO    : Gen at bus 23	: Pg=104.65, Qg=15.0 -> Pg=237.0, Qg=15.0
% INFO    : Gen at bus 23	: Pg=104.65, Qg=15.0 -> Pg=237.0, Qg=15.0
% INFO    : Gen at bus 23	: Pg=245.0, Qg=62.5 -> Pg=323.0, Qg=15.0
% INFO    :
% INFO    : === Generator Reactive Capacity Atleast Setpoint Value Notes ===
% INFO    : Gen at bus 1	: Qg 1.0, Qmin 0.0, Qmax 10.0 -> Qmin -1.2, Qmax 10.0
% INFO    : Gen at bus 1	: Qg 1.0, Qmin 0.0, Qmax 10.0 -> Qmin -1.2, Qmax 10.0
% INFO    : Gen at bus 2	: Qg 31.0, Qmin 0.0, Qmax 10.0 -> Qmin -37.2, Qmax 37.2
% INFO    : Gen at bus 2	: Qg 31.0, Qmin 0.0, Qmax 10.0 -> Qmin -37.2, Qmax 37.2
% INFO    : Gen at bus 2	: Qg 31.0, Qmin -25.0, Qmax 30.0 -> Qmin -37.2, Qmax 37.2
% INFO    : Gen at bus 2	: Qg 31.0, Qmin -25.0, Qmax 30.0 -> Qmin -37.2, Qmax 37.2
% INFO    : Gen at bus 7	: Qg 42.0, Qmin 0.0, Qmax 60.0 -> Qmin -50.4, Qmax 60.0
% INFO    : Gen at bus 7	: Qg 42.0, Qmin 0.0, Qmax 60.0 -> Qmin -50.4, Qmax 60.0
% INFO    : Gen at bus 7	: Qg 42.0, Qmin 0.0, Qmax 60.0 -> Qmin -50.4, Qmax 60.0
% INFO    : Gen at bus 13	: Qg 105.0, Qmin 0.0, Qmax 80.0 -> Qmin -126.0, Qmax 126.0
% INFO    : Gen at bus 13	: Qg 105.0, Qmin 0.0, Qmax 80.0 -> Qmin -126.0, Qmax 126.0
% INFO    : Gen at bus 13	: Qg 105.0, Qmin 0.0, Qmax 80.0 -> Qmin -126.0, Qmax 126.0
% INFO    : Gen at bus 14	: Qg 210.0, Qmin -50.0, Qmax 200.0 -> Qmin -252.0, Qmax 252.0
% INFO    : Gen at bus 15	: Qg 79.0, Qmin 0.0, Qmax 6.0 -> Qmin -94.8, Qmax 94.8
% INFO    : Gen at bus 15	: Qg 79.0, Qmin 0.0, Qmax 6.0 -> Qmin -94.8, Qmax 94.8
% INFO    : Gen at bus 15	: Qg 79.0, Qmin 0.0, Qmax 6.0 -> Qmin -94.8, Qmax 94.8
% INFO    : Gen at bus 15	: Qg 79.0, Qmin 0.0, Qmax 6.0 -> Qmin -94.8, Qmax 94.8
% INFO    : Gen at bus 15	: Qg 79.0, Qmin 0.0, Qmax 6.0 -> Qmin -94.8, Qmax 94.8
% INFO    : Gen at bus 15	: Qg 79.0, Qmin -50.0, Qmax 80.0 -> Qmin -94.8, Qmax 80.0
% INFO    : Gen at bus 21	: Qg -118.0, Qmin -50.0, Qmax 200.0 -> Qmin -141.6, Qmax 200.0
% INFO    :
% INFO    : === Generator Classification Notes ===
% INFO    : PEL    4   -     6.70
% INFO    : SYNC   1   -     0.00
% INFO    : COW    7   -    23.79
% INFO    : NG     21  -    69.51
% INFO    :
% INFO    : === Generator Active Capacity Stat Model Notes ===
% INFO    : Gen at bus 1 - PEL	: Pg=73.0, Pmax=20.0 -> Pmax=79   samples: 7
% INFO    : Gen at bus 1 - PEL	: Pg=73.0, Pmax=20.0 -> Pmax=211   samples: 1
% INFO    : Gen at bus 1 - PEL	: Pg=72.0, Pmax=76.0 -> Pmax=75   samples: 9
% INFO    : Gen at bus 1 - NG	: Pg=72.0, Pmax=76.0 -> Pmax=78   samples: 2
% INFO    : Gen at bus 2 - NG	: Pg=157.0, Pmax=20.0 -> Pmax=188   samples: 1
% WARNING : Failed to find a generator capacity within (157.0-785.0) after 100 samples, using percent increase model
% INFO    : Gen at bus 2 - PEL	: Pg=157.0, Pmax=20.0 -> Pmax=182   samples: 100
% INFO    : Gen at bus 2 - NG	: Pg=156.0, Pmax=76.0 -> Pmax=176   samples: 1
% INFO    : Gen at bus 2 - COW	: Pg=156.0, Pmax=76.0 -> Pmax=663   samples: 3
% INFO    : Gen at bus 7 - NG	: Pg=126.0, Pmax=100.0 -> Pmax=430   samples: 2
% INFO    : Gen at bus 7 - NG	: Pg=126.0, Pmax=100.0 -> Pmax=153   samples: 1
% INFO    : Gen at bus 7 - COW	: Pg=126.0, Pmax=100.0 -> Pmax=595   samples: 1
% INFO    : Gen at bus 13 - NG	: Pg=410.0, Pmax=197.0 -> Pmax=544   samples: 18
% INFO    : Gen at bus 13 - NG	: Pg=410.0, Pmax=197.0 -> Pmax=542   samples: 17
% INFO    : Gen at bus 13 - COW	: Pg=410.0, Pmax=197.0 -> Pmax=609   samples: 2
% INFO    : Gen at bus 14 - SYNC	: Pg=0.0, Pmax=0.0 -> Pmax=0   samples: 0
% INFO    : Gen at bus 15 - NG	: Pg=132.0, Pmax=12.0 -> Pmax=159   samples: 4
% INFO    : Gen at bus 15 - COW	: Pg=132.0, Pmax=12.0 -> Pmax=206   samples: 2
% INFO    : Gen at bus 15 - NG	: Pg=132.0, Pmax=12.0 -> Pmax=195   samples: 3
% INFO    : Gen at bus 15 - NG	: Pg=132.0, Pmax=12.0 -> Pmax=162   samples: 10
% INFO    : Gen at bus 15 - NG	: Pg=132.0, Pmax=12.0 -> Pmax=139   samples: 1
% INFO    : Gen at bus 15 - NG	: Pg=184.0, Pmax=155.0 -> Pmax=206   samples: 1
% WARNING : Failed to find a generator capacity within (522.0-2610.0) after 100 samples, using percent increase model
% INFO    : Gen at bus 16 - NG	: Pg=522.0, Pmax=155.0 -> Pmax=589   samples: 100
% INFO    : Gen at bus 18 - NG	: Pg=301.0, Pmax=400.0 -> Pmax=382   samples: 10
% INFO    : Gen at bus 21 - COW	: Pg=203.0, Pmax=400.0 -> Pmax=675   samples: 2
% INFO    : Gen at bus 22 - NG	: Pg=68.0, Pmax=50.0 -> Pmax=222   samples: 2
% INFO    : Gen at bus 22 - NG	: Pg=68.0, Pmax=50.0 -> Pmax=184   samples: 1
% INFO    : Gen at bus 22 - NG	: Pg=68.0, Pmax=50.0 -> Pmax=146   samples: 2
% INFO    : Gen at bus 22 - COW	: Pg=68.0, Pmax=50.0 -> Pmax=233   samples: 1
% INFO    : Gen at bus 22 - NG	: Pg=68.0, Pmax=50.0 -> Pmax=216   samples: 1
% INFO    : Gen at bus 22 - NG	: Pg=68.0, Pmax=50.0 -> Pmax=83   samples: 1
% INFO    : Gen at bus 23 - NG	: Pg=237.0, Pmax=155.0 -> Pmax=421   samples: 2
% INFO    : Gen at bus 23 - COW	: Pg=237.0, Pmax=155.0 -> Pmax=292   samples: 3
% INFO    : Gen at bus 23 - NG	: Pg=323.0, Pmax=350.0 -> Pmax=382   samples: 35
% INFO    :
% INFO    : === Generator Active Capacity LB Model Notes ===
% INFO    : Gen at bus 1	: Pmin=16.0 -> Pmin=8.0
% INFO    : Gen at bus 1	: Pmin=16.0 -> Pmin=8.0
% INFO    : Gen at bus 1	: Pmin=15.2 -> Pmin=7.6
% INFO    : Gen at bus 1	: Pmin=15.2 -> Pmin=7.6
% INFO    : Gen at bus 2	: Pmin=16.0 -> Pmin=8.0
% INFO    : Gen at bus 2	: Pmin=16.0 -> Pmin=8.0
% INFO    : Gen at bus 2	: Pmin=15.2 -> Pmin=7.6
% INFO    : Gen at bus 2	: Pmin=15.2 -> Pmin=7.6
% INFO    : Gen at bus 7	: Pmin=25.0 -> Pmin=12.5
% INFO    : Gen at bus 7	: Pmin=25.0 -> Pmin=12.5
% INFO    : Gen at bus 7	: Pmin=25.0 -> Pmin=12.5
% INFO    : Gen at bus 13	: Pmin=69.0 -> Pmin=34.5
% INFO    : Gen at bus 13	: Pmin=69.0 -> Pmin=34.5
% INFO    : Gen at bus 13	: Pmin=69.0 -> Pmin=34.5
% INFO    : Gen at bus 15	: Pmin=2.4 -> Pmin=1.2
% INFO    : Gen at bus 15	: Pmin=2.4 -> Pmin=1.2
% INFO    : Gen at bus 15	: Pmin=2.4 -> Pmin=1.2
% INFO    : Gen at bus 15	: Pmin=2.4 -> Pmin=1.2
% INFO    : Gen at bus 15	: Pmin=2.4 -> Pmin=1.2
% INFO    : Gen at bus 15	: Pmin=54.3 -> Pmin=27.15
% INFO    : Gen at bus 16	: Pmin=54.3 -> Pmin=27.15
% INFO    : Gen at bus 18	: Pmin=100.0 -> Pmin=50.0
% INFO    : Gen at bus 21	: Pmin=100.0 -> Pmin=50.0
% INFO    : Gen at bus 22	: Pmin=10.0 -> Pmin=5.0
% INFO    : Gen at bus 22	: Pmin=10.0 -> Pmin=5.0
% INFO    : Gen at bus 22	: Pmin=10.0 -> Pmin=5.0
% INFO    : Gen at bus 22	: Pmin=10.0 -> Pmin=5.0
% INFO    : Gen at bus 22	: Pmin=10.0 -> Pmin=5.0
% INFO    : Gen at bus 22	: Pmin=10.0 -> Pmin=5.0
% INFO    : Gen at bus 23	: Pmin=54.3 -> Pmin=27.15
% INFO    : Gen at bus 23	: Pmin=54.3 -> Pmin=27.15
% INFO    : Gen at bus 23	: Pmin=140.0 -> Pmin=70.0
% INFO    :
% INFO    : === Generator Reactive Capacity Atleast Max 50 Percent Active Model Notes ===
% INFO    : Gen at bus 1 - PEL	: Pmax 79.0, Qmin -1.2, Qmax 10.0 -> Qmin -40.0, Qmax 40.0
% INFO    : Gen at bus 1 - PEL	: Pmax 211.0, Qmin -1.2, Qmax 10.0 -> Qmin -106.0, Qmax 106.0
% INFO    : Gen at bus 1 - PEL	: Pmax 75.0, Qmin -25.0, Qmax 30.0 -> Qmin -38.0, Qmax 38.0
% INFO    : Gen at bus 1 - NG	: Pmax 78.0, Qmin -25.0, Qmax 30.0 -> Qmin -39.0, Qmax 39.0
% INFO    : Gen at bus 2 - NG	: Pmax 188.0, Qmin -37.2, Qmax 37.2 -> Qmin -94.0, Qmax 94.0
% INFO    : Gen at bus 2 - PEL	: Pmax 182.0, Qmin -37.2, Qmax 37.2 -> Qmin -91.0, Qmax 91.0
% INFO    : Gen at bus 2 - NG	: Pmax 176.0, Qmin -37.2, Qmax 37.2 -> Qmin -88.0, Qmax 88.0
% INFO    : Gen at bus 2 - COW	: Pmax 663.0, Qmin -37.2, Qmax 37.2 -> Qmin -332.0, Qmax 332.0
% INFO    : Gen at bus 7 - NG	: Pmax 430.0, Qmin -50.4, Qmax 60.0 -> Qmin -215.0, Qmax 215.0
% INFO    : Gen at bus 7 - NG	: Pmax 153.0, Qmin -50.4, Qmax 60.0 -> Qmin -77.0, Qmax 77.0
% INFO    : Gen at bus 7 - COW	: Pmax 595.0, Qmin -50.4, Qmax 60.0 -> Qmin -298.0, Qmax 298.0
% INFO    : Gen at bus 13 - NG	: Pmax 544.0, Qmin -126.0, Qmax 126.0 -> Qmin -272.0, Qmax 272.0
% INFO    : Gen at bus 13 - NG	: Pmax 542.0, Qmin -126.0, Qmax 126.0 -> Qmin -271.0, Qmax 271.0
% INFO    : Gen at bus 13 - COW	: Pmax 609.0, Qmin -126.0, Qmax 126.0 -> Qmin -305.0, Qmax 305.0
% INFO    : Gen at bus 15 - COW	: Pmax 206.0, Qmin -94.8, Qmax 94.8 -> Qmin -103.0, Qmax 103.0
% INFO    : Gen at bus 15 - NG	: Pmax 195.0, Qmin -94.8, Qmax 94.8 -> Qmin -98.0, Qmax 98.0
% INFO    : Gen at bus 15 - NG	: Pmax 206.0, Qmin -94.8, Qmax 80.0 -> Qmin -103.0, Qmax 103.0
% INFO    : Gen at bus 16 - NG	: Pmax 589.0, Qmin -50.0, Qmax 80.0 -> Qmin -295.0, Qmax 295.0
% INFO    : Gen at bus 18 - NG	: Pmax 382.0, Qmin -50.0, Qmax 200.0 -> Qmin -191.0, Qmax 200.0
% INFO    : Gen at bus 21 - COW	: Pmax 675.0, Qmin -141.6, Qmax 200.0 -> Qmin -338.0, Qmax 338.0
% INFO    : Gen at bus 22 - NG	: Pmax 222.0, Qmin -10.0, Qmax 16.0 -> Qmin -111.0, Qmax 111.0
% INFO    : Gen at bus 22 - NG	: Pmax 184.0, Qmin -10.0, Qmax 16.0 -> Qmin -92.0, Qmax 92.0
% INFO    : Gen at bus 22 - NG	: Pmax 146.0, Qmin -10.0, Qmax 16.0 -> Qmin -73.0, Qmax 73.0
% INFO    : Gen at bus 22 - COW	: Pmax 233.0, Qmin -10.0, Qmax 16.0 -> Qmin -117.0, Qmax 117.0
% INFO    : Gen at bus 22 - NG	: Pmax 216.0, Qmin -10.0, Qmax 16.0 -> Qmin -108.0, Qmax 108.0
% INFO    : Gen at bus 22 - NG	: Pmax 83.0, Qmin -10.0, Qmax 16.0 -> Qmin -42.0, Qmax 42.0
% INFO    : Gen at bus 23 - NG	: Pmax 421.0, Qmin -50.0, Qmax 80.0 -> Qmin -211.0, Qmax 211.0
% INFO    : Gen at bus 23 - COW	: Pmax 292.0, Qmin -50.0, Qmax 80.0 -> Qmin -146.0, Qmax 146.0
% INFO    : Gen at bus 23 - NG	: Pmax 382.0, Qmin -25.0, Qmax 150.0 -> Qmin -191.0, Qmax 191.0
% INFO    :
% INFO    : === Generator Setpoint Replacement Notes ===
% INFO    : Gen at bus 1	: Pg=73.0, Qg=1.0 -> Pg=43.5, Qg=0.0
% INFO    : Gen at bus 1	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 1	: Pg=73.0, Qg=1.0 -> Pg=109.5, Qg=0.0
% INFO    : Gen at bus 1	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 1	: Pg=72.0, Qg=1.0 -> Pg=41.3, Qg=0.0
% INFO    : Gen at bus 1	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 1	: Pg=72.0, Qg=1.0 -> Pg=42.8, Qg=0.0
% INFO    : Gen at bus 1	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 2	: Pg=157.0, Qg=31.0 -> Pg=98.0, Qg=0.0
% INFO    : Gen at bus 2	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 2	: Pg=157.0, Qg=31.0 -> Pg=95.0, Qg=0.0
% INFO    : Gen at bus 2	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 2	: Pg=156.0, Qg=31.0 -> Pg=91.8, Qg=0.0
% INFO    : Gen at bus 2	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 2	: Pg=156.0, Qg=31.0 -> Pg=335.3, Qg=0.0
% INFO    : Gen at bus 2	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 7	: Pg=126.0, Qg=42.0 -> Pg=221.25, Qg=0.0
% INFO    : Gen at bus 7	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 7	: Pg=126.0, Qg=42.0 -> Pg=82.75, Qg=0.0
% INFO    : Gen at bus 7	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 7	: Pg=126.0, Qg=42.0 -> Pg=303.75, Qg=0.0
% INFO    : Gen at bus 7	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 13	: Pg=410.0, Qg=105.0 -> Pg=289.25, Qg=0.0
% INFO    : Gen at bus 13	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 13	: Pg=410.0, Qg=105.0 -> Pg=288.25, Qg=0.0
% INFO    : Gen at bus 13	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 13	: Pg=410.0, Qg=105.0 -> Pg=321.75, Qg=0.0
% INFO    : Gen at bus 13	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 14	: Pg=0.0, Qg=210.0 -> Pg=0.0, Qg=0.0
% INFO    : Gen at bus 14	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 15	: Pg=132.0, Qg=79.0 -> Pg=80.1, Qg=0.0
% INFO    : Gen at bus 15	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 15	: Pg=132.0, Qg=79.0 -> Pg=103.6, Qg=0.0
% INFO    : Gen at bus 15	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 15	: Pg=132.0, Qg=79.0 -> Pg=98.1, Qg=0.0
% INFO    : Gen at bus 15	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 15	: Pg=132.0, Qg=79.0 -> Pg=81.6, Qg=0.0
% INFO    : Gen at bus 15	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 15	: Pg=132.0, Qg=79.0 -> Pg=70.1, Qg=0.0
% INFO    : Gen at bus 15	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 15	: Pg=184.0, Qg=79.0 -> Pg=116.575, Qg=0.0
% INFO    : Gen at bus 15	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 16	: Pg=522.0, Qg=-34.0 -> Pg=308.075, Qg=0.0
% INFO    : Gen at bus 16	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 18	: Pg=301.0, Qg=32.0 -> Pg=216.0, Qg=4.5
% INFO    : Gen at bus 18	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 21	: Pg=203.0, Qg=-118.0 -> Pg=362.5, Qg=0.0
% INFO    : Gen at bus 21	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 22	: Pg=68.0, Qg=-9.0 -> Pg=113.5, Qg=0.0
% INFO    : Gen at bus 22	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 22	: Pg=68.0, Qg=-9.0 -> Pg=94.5, Qg=0.0
% INFO    : Gen at bus 22	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 22	: Pg=68.0, Qg=-9.0 -> Pg=75.5, Qg=0.0
% INFO    : Gen at bus 22	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 22	: Pg=68.0, Qg=-9.0 -> Pg=119.0, Qg=0.0
% INFO    : Gen at bus 22	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 22	: Pg=68.0, Qg=-9.0 -> Pg=110.5, Qg=0.0
% INFO    : Gen at bus 22	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 22	: Pg=68.0, Qg=-9.0 -> Pg=44.0, Qg=0.0
% INFO    : Gen at bus 22	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 23	: Pg=237.0, Qg=15.0 -> Pg=224.075, Qg=0.0
% INFO    : Gen at bus 23	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 23	: Pg=237.0, Qg=15.0 -> Pg=159.575, Qg=0.0
% INFO    : Gen at bus 23	: Vg=1.0 -> Vg=1.0
% INFO    : Gen at bus 23	: Pg=323.0, Qg=15.0 -> Pg=226.0, Qg=0.0
% INFO    : Gen at bus 23	: Vg=1.0 -> Vg=1.0
% INFO    :
% INFO    : === Writing Matpower Case File Notes ===

author: power-grid-lib

repo: pglib-opf


text:
function z=hatmatrix(varargin)

fit = locfit(varargin{:},'module','hatm');
z = lfknots(fit)';

return;

author: buzsakilab

repo: buzcode

save_path: github-repos/MATLAB/buzsakilab-buzcode


text:
function [pv, ph] = splitpg(pg)
% [pv, ph] = splitpg(pg)

if iscell(pg)
    for f = 1:numel(pg)
        pv{f} = [pg{f}(:, 1) sum(pg{f}(:, 2:6), 2) pg{f}(:, 7)];
        ph{f} = pg{f}(:, 2:6) ./ repmat(max(pv{f}(:, 2), 1E-6), [1 5]);
    end
else
    pv = [pg(:, 1) sum(pg(:, 2:6), 2) pg(:, 7)];
    ph = pg(:, 2:6) ./ repmat(max(pv(:, 2), 1E-6), [1 5]);
end

author: zouchuhang

repo: LayoutNet


text:
function [ x, seed ] = extreme_values_sample ( a, b, seed )

%*****************************************************************************80
%
%% EXTREME_VALUES_SAMPLE samples the Extreme Values PDF.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    09 September 2004
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real A, B, the parameters of the PDF.
%    0.0 < B.
%
%    Input, integer SEED, a seed for the random number generator.
%
%    Output, real X, a sample of the PDF.
%
%    Output, integer SEED, an updated seed for the random number generator.
%
  [ cdf, seed ] = r8_uniform_01 ( seed );

  x = extreme_values_cdf_inv ( cdf, a, b );

  return
end

author: johannesgerer

repo: jburkardt-m


function X = trans_cam2fisheye_X(Xcam, M, D)

xcam = Xcam(1, :) ;
ycam = Xcam(2, :) ;
zcam = Xcam(3, :) ;

[x, y] = trans_cam2fisheye(xcam, ycam, zcam, M, D);

X = [x; y; ones(1, size(x, 2))] ;

end


text:
classdef OrientationUpdater < handle

    properties (GetAccess = public, SetAccess = protected)
        alpha
    end

    properties (Access = protected)
        eigenVectors
        eigenValues
        optimalIndexOrientation
    end

    methods (Access = public, Static)

        function obj = create(cParams)
           f = OrientationUpdaterFactory();
           obj = f.create(cParams);
        end

    end

    methods (Access = public)

        function compute(obj,cParams)
            obj.eigenVectors = cParams.pD;
            obj.eigenValues  = cParams.pS;
            obj.computeOptimalIndexOrientation();
            obj.computeOrientation();
        end

    end

    methods (Access = private)

        function computeOrientation(obj)
            pD  = obj.eigenVectors;
            ind = obj.optimalIndexOrientation;
            isFirstOptimal  = ind == 1;
            isSecondOptimal = ind == 2;
            dir(:,isFirstOptimal)  = squeeze(pD(:,1,isFirstOptimal));
            dir(:,isSecondOptimal) = squeeze(pD(:,2,isSecondOptimal));
            obj.alpha = dir;
        end

    end

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

end

author: SwanLab

repo: Swan

save_path: github-repos/MATLAB/SwanLab-Swan


text:
function w = padua_weights ( l )

%*****************************************************************************80
%
%% PADUA_WEIGHTS returns quadrature weights for Padua points.
%
%  Discussion:
%
%    The order of the weights corresponds to the ordering used
%    by the companion function padua_points().
%
%    Caliari, de Marchi and Vianello supplied a MATLAB code pdwtsMM
%    which carries out this same computation in a way that makes
%    more efficient use of MATLAB's vector and matrix capabilities.
%    This version of the computation was painfully rewritten to display
%    the individual scalar computations, so that it could be translated
%    into other languages.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    11 June 2014
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Marco Caliari, Stefano de Marchi, Marco Vianello,
%    Bivariate interpolation on the square at new nodal sets,
%    Applied Mathematics and Computation,
%    Volume 165, Number 2, 2005, pages 261-274.
%
%  Parameters:
%
%    Input, integer L, the level of the set.
%    0 <= L
%
%    Output, real W((L+1)*(L+2)/2), the quadrature weights.
%
  if ( l == 0 )
    w = 4.0;
    return
  end
%
%  Relatives of L/2:
%
  lp1h = floor ( ( l + 1 ) / 2 );
  lp2h = floor ( ( l + 2 ) / 2 );
  lp3h = floor ( ( l + 3 ) / 2 );
%
%  TE1, TE2, TO1, TO2:
%  Even and odd Chebyshev polynomials on subgrids 1 and 2.
%
  te1 = zeros(lp2h,lp2h);
  for j = 1 : lp2h
    for i = 1 : lp2h
      te1(i,j) = cos ( 2 * ( i - 1 ) * ( 2 * j - 2 ) * pi / l );
    end
  end
  te1(2:lp2h,1:lp2h) = te1(2:lp2h,1:lp2h) * sqrt ( 2.0 );

  to1 = zeros(lp2h,lp1h);
  for j = 1 : lp1h
    for i = 1 : lp2h
      to1(i,j) = cos ( 2 * ( i - 1 ) * ( 2 * j - 1 ) * pi / l );
    end
  end
  to1(2:lp2h,1:lp1h) = to1(2:lp2h,1:lp1h) * sqrt ( 2.0 );

  te2 = zeros(lp2h,lp3h);
  for j = 1 : lp3h
    for i = 1 : lp2h
      te2(i,j) = ...
        cos ( 2 * ( i - 1 ) * ( 2 * j - 2 ) * pi / ( l + 1 ) );
    end
  end
  te2(2:lp2h,1:lp3h) = te2(2:lp2h,1:lp3h) * sqrt ( 2.0 );

  to2 = zeros(lp2h,lp2h);
  for j = 1 : lp2h
    for i = 1 : lp2h
      to2(i,j) = ...
        cos ( 2 * ( i - 1 ) * ( 2 * j - 1 ) * pi / ( l + 1 ) );
    end
  end
  to2(2:lp2h,1:lp2h) = to2(2:lp2h,1:lp2h) * sqrt ( 2.0 );
%
%  MOM: Moments matrix for even * even pairs.
%
  mom = zeros(lp2h,lp2h);

  for j = 1 : lp2h
    mj = 2.0 * sqrt ( 2.0 ) / ( 1.0 - ( 2 * j - 2 ) ^2 );
    for i = 1 : lp2h + 1 - j
      mi = 2.0 * sqrt ( 2.0 ) / ( 1.0 - ( 2 * i - 2 ) ^2 );
      mom(i,j) = mi * mj;
    end
  end

  mom(1,1:lp2h) = mom(1,1:lp2h) / sqrt ( 2.0 );
  mom(1:lp2h,1) = mom(1:lp2h,1) / sqrt ( 2.0 );

  if ( mod ( l, 2 ) == 0 )
    mom(lp2h,1) = mom(lp2h,1) / 2.0;
  end
%
%  TMTOE and TMTEO: matrix products.
%
  tmtoe = zeros(lp2h,lp2h);

  for j2 = 1 : lp2h
    for i2 = 1 : lp2h+1-j2
      for j = 1 : lp2h
        for i = 1 : lp2h
          tmtoe(i,j) = tmtoe(i,j) + to2(i2,i) * mom(j2,i2) * te1(j2,j);
        end
      end
    end
  end

  tmteo = zeros(lp3h,lp1h);

  for j2 = 1 : lp2h
    for i2 = 1 : lp2h+1-j2
      for j = 1 : lp1h
        for i = 1 : lp3h
          tmteo(i,j) = tmteo(i,j) + te2(i2,i) * mom(j2,i2) * to1(j2,j);
        end
      end
    end
  end
%
%  W1 and W2: Interpolation weight matrices.
%
  w1 = 2.0 * ones(lp2h,lp2h) / ( l * ( l + 1 ) );

  w1(1:lp2h,1) = w1(1:lp2h,1) / 2.0;

  if ( mod ( l, 2 ) == 0 )
    w1(1:lp2h,lp2h) = w1(1:lp2h,lp2h) / 2.0;
    w1(lp2h,1:lp2h) = w1(lp2h,1:lp2h) / 2.0;
  end

  w2 = 2.0 * ones(lp3h,lp1h) / ( l * ( l + 1 ) );
  w2(1,1:lp1h) = w2(1,1:lp1h) / 2.0;

  if ( mod ( l, 2 ) == 1 )
    w2(lp3h,1:lp1h) = w2(lp3h,1:lp1h) / 2.0;
    w2(1:lp3h,lp1h) = w2(1:lp3h,lp1h) / 2.0;
  end
%
%  Cubature weights as matrices on the subgrids.
%
  for j = 1 : lp2h
    for i = 1 : lp2h
      w1(i,j) = w1(i,j) * tmtoe(i,j);
    end
  end

  for j = 1 : lp1h
    for i = 1 : lp3h
      w2(i,j) = w2(i,j) * tmteo(i,j);
    end
  end
%
%  Pack weight matrices W1 and W2 into the vector W.
%
  n = ( ( l + 1 ) * ( l + 2 ) ) / 2;
  w = zeros(n,1);

  if ( mod ( l, 2 ) == 0 )

    for i = 1 : lp2h
      for j = 1 : lp2h
        w(i+(2*j-2)*lp2h) = w1(i,j);
      end
    end

    for i = 1 : lp3h
      for j = 1 : lp1h
        w(i+(2*j-1)*lp2h) = w2(i,j);
      end
    end

  else

    for j = 1 : lp1h
      for i = 1 : lp2h
        w(i+(j-1)*(l+2)) = w1(i,j);
      end
    end

    for j = 1 : lp1h
      for i = 1 : lp3h
        w(i+lp2h+(j-1)*(l+2)) = w2(i,j);
      end
    end

  end

  return
end


text:
function triangulation_test27 ( )

%*****************************************************************************80
%
%% TEST27 tests TRIANGULATION_ORDER6_VERTEX_COUNT.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    24 August 2006
%
%  Author:
%
%    John Burkardt
%
  dim_num = 2;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'TEST27\n' );
  fprintf ( 1, '  TRIANGULATION_ORDER6_VERTEX_COUNT counts the \n' );
  fprintf ( 1, '  vertex nodes and midside nodes in\n' );
  fprintf ( 1, '  an order 6 triangulation.\n' );

  [ node_num, triangle_num, hole_num ] = ...
    triangulation_order6_example1_size ( );

  [ node_xy, triangle_node, triangle_neighbor ] = ...
    triangulation_order6_example1 ( node_num, triangle_num );

  [ vertex_num, midside_num ] = triangulation_order6_vertex_count ( ...
    node_num, triangle_num, triangle_node );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of nodes         = %d\n', node_num );
  fprintf ( 1, '  Number of vertex nodes  = %d\n', vertex_num );
  fprintf ( 1, '  Number of midside nodes = %d\n', midside_num );

  return
end


text:
% USERDATAPNT  User data for SLAMTB - Example with points.
%   This is a particular case of USERDATA.M. It is intended for
%   demonstration of the SLAM toolbox with points. Try the following point
%   types in Opt.init.initType:
%       'idpPnt'    Inverse depth points
%       'ahmPnt'    Anchored homogeneous points
%       'hmgPnt'    Homogeneous points
%
%   See also USERDATA.

%   Copyright 2008-2009 Joan Sola @ LAAS-CNRS.

% Time variables
%   - sampling time, first and last frames
Time = struct(...
  'dt',                   .1,...          % sampling time, seconds
  'firstFrame',           1,...           % first frame #
  'lastFrame',            400);           % last frame #

% Simulated world
%   - Simulation landmark sets, playground dimensions
World = struct(...
  'points',           thickCloister(-6,6,-6,6,1,7),... % 3d point landmarks - see THICKCLOISTER.
  'segments',         []);  % 3D segments - see HOUSE.

% Robot things with their controls
%   - each robot's type and initial configuration, and controls.
%   - motion models (add new model strings if you need more):
%       'constVel'    6D Constant velocity model
%       'odometry'    6D Odometry model
%   - See EULERANGLES for orientations specifications.
Robot{1} = struct(...                     % ODOMETRY EXAMPLE
  'id',                 1,...           % robot identifier
  'name',               'Dala',...      % robot name
  'type',               'atrv',...      % type of robot
  'motion',             'odometry',...  % motion model
  'position',           [0;-5;0],...     % robot position in map
  'orientationDegrees', [0;0;0],...     % orientation, in degrees, roll pitch yaw.
  'positionStd',        [0;0;0],...     % position error, std
  'orientationStd',     [0;0;0],...     % orient. error, std, in degrees
  'dx',                 [.08;0;0],...     % position increment 8
  'daDegrees',          [0;0;0.9],...     % angle increment, degrees 9
  'dxStd',              0.005*[1;1;1],...  % odo linear error std
  'daStd',              0.05*[1;1;1]);     % odo ang error std, degrees

% Robot{2} = struct(...                     % CONSTANT VELOCITY EXAMPLE
%   'id',                 3,...           % robot identifier
%   'name',               'Dala',...      % robot name
%   'type',               'atrv',...      % type of robot
%   'motion',             'constVel',...  % motion model
%   'position',           [1;0;0],...     % robot position in map
%   'orientationDegrees', [0;0;45],...    % orientation, in degrees, roll pitch yaw.
%   'positionStd',        [0;0;0],...     % position error, std
%   'orientationStd',     [0;0;0],...     % orient. error, std, degrees
%   'velocity',           [1;0;0],...     % lin. velocity
%   'angularVelDegrees',  [0;0;10],...    % ang. velocity, in degrees
%   'velStd',             [0;0;0],...     % lin. vel. error, std
%   'angVelStd',          [0;0;0],...     % ang. vel. error, std, degrees
%   'dv',                 [0;0;0],...     % veolcity increment
%   'dwDegrees',          [0;0;0],...     % ang. vel. increment, degrees
%   'dvStd',              [0;0;0],...     % vel perturbation std
%   'dwStd',              [0;0;1]);       % ang vel pert. std, degrees

% Sensor things
%   - each sensor's type and parameters, noise, non-measurable prior.
%   - Sensor types (add new type strings if you need more):
%       'pinHole'   Pin-hole camera
%   - See EULERANGLES for orientations specifications.
Sensor{1} = struct(...
  'id',                 1,...           % sensor identifier
  'name',               'Micropix',...  % sensor name
  'type',               'pinHole',...   % type of sensor
  'robot',              1,...           % robot where it is mounted
  'position',           [0;0;.6],...    % position in robot
  'orientationDegrees', [-90;0;-90],... % orientation in robot, roll pitch yaw
  'positionStd',        [0;0;0],...     % position error std
  'orientationStd',     [0;0;0],...     % orient. error std
  'imageSize',          [640;480],...   % image size
  'pixErrorStd',        1.0,...         % pixel error std
  'intrinsic',          [320;240;320;320],... % intrinsic params [u0 v0 au av]
  'distortion',         [],...          % distortion params
  'frameInMap',         false,...       % add sensor frame in slam map?
  'imGrid',             struct(...      % grid for Active Search
    'numCells',         [8;6],...         % number of H and V grid cells
    'skipOuter',        true));           % skip outer cells for initialization?

% Sensor{2} = struct(...
%   'id',                 2,...           % sensor identifier
%   'name',               'Micropix',...      % sensor name
%   'type',               'pinHole',...   % type of sensor
%   'robot',              1,...           % robot where it is mounted
%   'position',           [0;-0.15;.6],...     % position in robot
%   'orientationDegrees', [-90;0;-90],...      % orientation in robot, roll pitch yaw
%   'positionStd',        [0;0;0],...     % position error std
%   'orientationStd',     [1.5;1.5;1.5],...     % orient. error std
%   'imageSize',          [640;480],...   % image size
%   'pixErrorStd',        1.0,...         % pixel error std
%   'intrinsic',          [320;240;320;320],... % intrinsic params
%   'distortion',         [],...          % distortion params
%   'frameInMap',         false);         % add sensor frame in slam map?

% Omnidirectional camera model -> MegaPixel Fish Eye lens as example (FoV is ~190 deg )
% k           = [668 438 1 0 0]';
% invProjDist = [4.473e+2 -0.000e+0 -1.068e-3 1.184e-6 -1.856e-9]';
% projDist    = [6.447e+2 -3.410e+2 -2.901e+1 -5.770e+1 1.849e+1 5.415e+0 5.065e+1 -5.614e+1 1.591e+1 0 0]';
% Sensor{1} = struct(...
%   'id',                 1,...           % sensor identifier
%   'name',               'FrontCam',...  % sensor name
%   'type',               'omniCam',...   % type of sensor
%   'robot',              1,...           % robot where it is mounted
%   'position',           [0.2;0;1.2],... % position in robot
%   'orientationDegrees', [-120;0;-90],...% orientation in robot, roll pitch yaw.
%   'positionStd',        [0;0;0],...     % position error std
%   'orientationStd',     [0;0;0],...     % orient. error std
%   'imageSize',          [1280;800],...  % image size
%   'pixErrorStd',        1.0,...         % pixel error std
%   'intrinsic',          k,...           % intrinsic params: [xc yc c d e]';
%   'distortion',         projDist,...    % distortion params -> polynom for projection to cam sensor
%   'invDistortion',      invProjDist,... % distortion params -> polynom for inv proj from cam sensor
%   'frameInMap',         false,...       % add sensor frame in slam map?
%   'imGrid',             struct(...      % grid for Active Search
%     'numCells',         [8;6],...       % number of H and V grid cells
%     'skipOuter',        true));         % skip outer cells for initialization?

% Estimation options
Opt = struct(...
  'map',              struct(...    % options for the map
    'numLmks',        73,...         % number of 3d landmarks
    'lmkSize',        7),...         % Size of landmark
  'correct',          struct(...    % options for lmk correction
    'reprojectLmks',  true,...       % reproject lmks after active search?
    'reparametrize',  true,...       % reparametrize lmk?
    'nUpdates',       10,...         % max simultaneus updates
    'MD2th',          9,...          % Threshold on Mahalanobis distance squared
    'linTestIdp',     0.1,...        % threshold on IDP linearity test
    'lines',          struct(...     % options for line corrections
      'innType',      'ortDst',...    % innovation type for lines
      'extPolicy',    false,...       % line extending policy ?
      'extSwitch',    10)),...        % extension policy switch point in pixels
  'init',             struct(...    % Options for initialization
    'nbrInits',       [10 1],...      % number of inits [firstFrame, otherFrames]
    'initType',       'ahmPnt',...   % Type of lmk to use for init
    'idpPnt',         struct(...     % inverse-distance prior
      'nonObsMean',   0.01,...         % mean of non obs
      'nonObsStd',    0.5),...         % std of non obs
    'plkLin',         struct(...     % Plucker prior
      'nonObsMean',   [.1;0],...      % mean of non obs
      'nonObsStd',    [.25;1])),...   % std of non obs
  'obs',              struct(...    % Observation options
    'lines',          struct(...     % lines options
      'minLength',    20)));          % minimum segment length

% Simulation options
%   - random
SimOpt = struct(...
  'random',           struct(...      % random generator options
    'newSeed',        true,...         % select new random seed?
    'fixedSeed',      1,...            % random seed for non-random runs
    'seed',           []),...          % current seed
  'obs',              Opt.obs);       % Observation options

% Figure options
%   - view, projection, video, ellipses.
%   - figure projections - mapProj:
%       'persp'     Perspective
%       'ortho'     Orthographic
%   - 3D figure views - mapView - see MAPOBSERVER.
%       [a,e,f]     Custom azimuth/elevation/FOV vector. Distance automatic
%       [a,e,f,d]   custom az/el/fov/distance vector.
%   - 3D figure predefined views (edit mapObserver.m to create/edit views):
%       'top'       Top view
%       'side'      Side view
%       'view'      Generic view
%       'normal'    Normal view
%   - objects colors - two options for color specification:
%       'rgbcmykw'  1-char predifined Matlab colors
%       [r g b]     RGB color vector. [0 0 0] is black, [1 1 1] is white.
FigOpt = struct(...
  'renderer',       'opengl',...    % renderer
  'rendPeriod',     1,...           % frames to skip for faster processing
  'createVideo',    false,...       % create video sequences?
  'map',            struct(...      % map figure options
    'size',         [320 240],...   % map figure size
    'lims',        struct(...       % playground limits
      'xMin',            -10,...
      'xMax',             10,...
      'yMin',            -10,...
      'yMax',             10,...
      'zMin',            -10,...
      'zMax',             10),...
    'proj',         'persp',...     % projection of the 3d figure
    'view',         'view',...      % viewpoint of the 3d figure [30 45 40 20]
    'orbit',        [0 0],...       % AZ and EL orbit angle increments
    'showSimLmk',   false,...       % show simulated landmarks?
    'showEllip',    true,...        % show ellipsoids?
    'colors',       struct(...      % map figure colors
      'border',     [1 1 1],...      %   [r g b]
      'axes',       [0 0 0],...      % with:
      'bckgnd',     [1 1 1],...      %   [0 0 0] black
      'simLmk',     .3*[1 1 1],...   %   [1 1 1] white
      'defPnt',     struct(...       % euclidean point colors
        'mean',     'b',...           % mean dot
        'ellip',    [.7 .7 1]),...    % ellipsoid
      'othPnt',     struct(...       % other point colors
        'mean',     'r',...           % mean dot
        'ellip',    [1 .7 .7]),...    % ellipsoid
      'defLin',     struct(...       % Plucker line colors
        'mean',     [0 .8 0],...      % mean line
        'ellip',    [.6 1 .6]),...    % ellipsoid
      'othLin',     struct(...       % Plucker line colors
        'mean',     [.8 0 0],...      % mean line
        'ellip',    [1 .6 .6]),...    % ellipsoid
      'simu',       'b',...          %   or 'r', 'b', etc.
      'est',        'g',...          % estimated robots and sensors
      'ground',     [.8 .8 .8],...   % simulated robots and sensors
      'label',      [.0 .5 0])),...  % landmark ID labels
  'sensor',         struct(...      % sensor figures options
    'size',         [320 240],...    % sensor figure size
    'showEllip',    false,...        % show ellipses?
    'colors',       struct(...       % Sensor figure colors:
      'border',     .8*[1 1 1],...    %
      'axes',       [0 0 0],...       %
      'bckgnd',     [1 1 1],...       %
      'raw',        .3*[1 1 1],...    %
      'defPnt',     struct(...       % Default point colors
        'updated',  'c',...           % updated
        'predicted','b'),...          % predicted
      'othPnt',     struct(...       % other point colors
        'updated',  'r',...           % updated
        'predicted','m'),...          % predicted
      'defLin',     struct(...       % Default line colors
        'meas',     'b',...           % measurement
        'mean',     'g',...           % mean line
        'ellip',    'y'),...          % ellipsoid
      'othLin',     struct(...       % other line colors
        'meas',     'b',...           % measurement
        'mean',     'm',...           % mean line
        'ellip',    'r'),...          % ellipsoid
      'label',      [.5 .5 .5])));    %

% Experiment options
%   - site name, series gathered, estimation run number
ExpOpt = struct(...
  'root',         '~/SLAM/',...         % root directory
  'site',         'simu',...            % Name of the site
  'dataRun',      1,...                 % Run # on this site
  'estimateRun',  1,...                 % slam run for data and site
  'lmkTypes',     Opt.init.initType,... % types of landmarks used
  'sensingType',  'mono',...            % sensing mode
  'mappingType',  'single');            % mapping mode

% ========== End of function - Start GPL license ==========

%   # START GPL LICENSE

%---------------------------------------------------------------------
%
%   This file is part of SLAMTB, a SLAM toolbox for Matlab.
%
%   SLAMTB 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.
%
%   SLAMTB 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 SLAMTB.  If not, see <http://www.gnu.org/licenses/>.
%
%---------------------------------------------------------------------

%   SLAMTB is Copyright:
%   Copyright (c) 2008-2010, Joan Sola @ LAAS-CNRS,
%   Copyright (c) 2010-2013, Joan Sola,
%   Copyright (c) 2014-2015, Joan Sola @ IRI-UPC-CSIC,
%   SLAMTB is Copyright 2009
%   by Joan Sola, Teresa Vidal-Calleja, David Marquez and Jean Marie Codol
%   @ LAAS-CNRS.
%   See on top of this file for its particular copyright.

%   # END GPL LICENSE

author: joansola

repo: slamtb

save_path: github-repos/MATLAB/joansola-slamtb


text:
function [n, xout] = histx(varargin)
% A wrapper for hist that picks the "ideal" number of bins to use if
% unspecified.
%
% N = HISTX(Y) bins the elements of Y into M equally spaced containers and
% returns the number of elements in each container.  If Y is a matrix, HIST
% works down the columns.  The value of M is the middle (median) value of
% the optimal number of bins calculated using the Freedman-Diaconis, Scott
% and Sturges methods.  See below for further information on these methods.
%
% N = HISTX(Y,M), where M is a scalar, uses M bins.  (This is identical to
% N = HIST(Y,M).)
%
% N = HISTX(Y, X), where X is a vector, returns the distribution of Y among
% bins with centers specified by X. The first bin includes data between
% -inf and the first center and the last bin includes data between the last
% bin and inf. Note: Use HISTC if it is more natural to specify bin edges
% instead.  (This is identical to N = HIST(Y,X).)
%
% N = HISTX(Y, METHOD), where METHOD is a string chooses the number of bins
% as follows:
%
% 'fd': The Freedman-Diaconis method, based upon the inter-quartile range
% and number of data, is used.
% 'scott': The Scott method, based upon the sample standard deviation and
% nnumber of data, is used.
% 'sturges': The Sturges method, based upon the number of data, is used.
% 'middle': All three methods are tried, and the middle value is used.
%
% N = HISTX(Y, [], MINIMUM), where MINIMUM is a numeric scalar, defines the
% smallest acceptable number of bins.
%
% N = HISTX(Y, [], [], MAXIMUM), where MAXIMUM is a numeric scalar, defines the
% largest acceptable number of bins.
%
% HISTX(...) without output arguments produces a histogram bar plot of the
% results. The bar edges on the first and last bins may extend to cover the
% min and max of the data unless a matrix of data is supplied.
%
% HISTX(Y, 'all') produces three histograms in a new figure window, drawn
% with the number of bins calculated using each of the three methods.
%
% HISTX(AX, ...) plots into AX instead of GCA.
%
% Notes:
% 1. When the method chosen is 'all', any axes inputted will be ignored
% with a warning.  Likewise for output arguments.
%
% 2. References for the methods can be found in the help page for
% CALCNBINS.
%
% Examples:
% y = randn(10000,1);
% histx(y)
% histx(y, 'all')
%
% See also: CALCNBINS, HIST.
%
% $ Author: Richard Cotton $		$ Date: 2008/08/28 $    $ Version 1.1 $

% Check there is at least one input, and see if the first input is an axis.
error(nargchk(1,inf,nargin,'struct'));
[cax,args,nargs] = axescheck(varargin{:});

plotall = false;
y = args{1};

% If the number of bins wasn't specified, calculate it using calcnbins.
if nargs < 4 || isempty(args{4})
   args{4} = []; % this also sets missing arguments before this positon to [].
end

if ~isempty(args{2}) && isnumeric(args{2})
   nbins = args{2};
else
   nbins = calcnbins(y, args{2}, args{3}, args{4});
   if ischar(args{2}) && strcmpi(args{2}, 'all')
      plotall = true;
   end
end

% Plot the histogram(s)
if plotall
   if nargout > 0
      warning('histx:ignoreargout', 'No arguments will be returned when the method is "all".');
   end
   if ~isempty(cax)
      warning('histx:ignoreaxes', 'The input axes are ignored when the method is "all".');
   end
   n = [];
   xout = [];
   figure();
   subplot(3, 1, 1); hist(y, nbins.fd);
   title('Freedman-Diaconis'' method');
   subplot(3, 1, 2); hist(y, nbins.scott);
   title('Scott''s method');
   subplot(3, 1, 3); hist(y, nbins.sturges);
   title('Sturges'' method');
else
   if nargout==0
      if isempty(cax)
         hist(y, nbins);
      else
         hist(cax, y, nbins);
      end
   else
      if isempty(cax)
      [n, xout] = hist(y, nbins);
   else
      [n, xout] = hist(cax, y, nbins);
      end
   end
end

author: Sable

repo: mcbench-benchmarks


text:
function v=simple_endo_priors(obj,filtration) %#ok<INUSD>

% this file demonstrates how to setup a simple endogenous prior problem

nconstr=5;

is_initial=nargin==0;

if is_initial

    v = cell(nconstr,1);

else

    myirfs=irf(obj);

    C_A=double(myirfs.EPS_A.C);

    v = zeros(nconstr,1);

end

pointer=0;

for ii=1:nconstr

    pointer=pointer+1;

    if is_initial

        v{pointer}={0.005,2*0.005,'gamma'};

    else

        v(pointer)=C_A(pointer+1);

    end

end

if is_initial

    v = struct('priors',{v},...
        'kf_filtering_level',0);

end

end

author: jmaih


text:
function B = pixeldup(A, m, n)
%PIXELDUP Duplicates pixels of an image in both directions.
%   B = PIXELDUP(A, M, N) duplicates each pixel of A M times in the
%   vertical direction and N times in the horizontal direction.
%   Parameters M and N must be integers.  If N is not included, it
%   defaults to M.

%   Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
%   Digital Image Processing Using MATLAB, Prentice-Hall, 2004
%   $Revision: 1.4 $  $Date: 2003/06/14 16:29:54 $

% Check inputs.
if nargin < 2
   error('At least two inputs are required.');
end
if nargin == 2
   n = m;
end

% Generate a vector with elements 1:size(A, 1).
u = 1:size(A, 1);

% Duplicate each element of the vector m times.
m = round(m); % Protect against nonintergers.
u = u(ones(1, m), :);
u = u(:);

% Now repeat for the other direction.
v = 1:size(A, 2);
n = round(n);
v = v(ones(1, n), :);
v = v(:);
B = A(u, v);

repo: weiyanmin


text:
% Computes gain using the covariance matrix.
% Copyrights Farhat Masood (NUST) Pakistan

function [k,s] = kfilter(A,C,V1,V2,V12)%function [k,s] = kfilter(A,C,V1,V2,V12)%KFILTER can have arguments: (A,C,V1,V2) if there are no cross% products, V12=0.%     KFILTER calculates the kalman gain, k, and the stationary%     covariance matrix, s, using the Kalman filter for:%  %		x[t+1] = Ax[t] + Bu[t] + w1[t+1]%               y[t] = Cx[t] + Du[t] + w2[t]%%               E [w1(t+1)] [w1(t+1)]' =  [V1   V12;%                 [ w2(t) ] [ w2(t) ]      V12' V2 ]%%  where x is the mx1 vector of states, u is the nx1 vector of controls, y is%  the px1 vector of observables, A is mxm, B is mxn, C is pxm, V1 is mxm,%  V2 is pxp, V12 is mxp.%m=max(size(A));[rc,cc]=size(C);if nargin==4; V12=zeros(m,rc); end;if (rank(V2)==rc);  A=A-(V12/V2)*C;  V1=V1-V12*(V2\V12');  [k,s]=doubleo(A,C,V1,V2);  k=k+(V12/V2);else;  s0=.01*eye(m);  dd=1;  it=1;  maxit=1000;  while (dd>1e-8 & it<=maxit);    k0= (A*s0*C'+V12)/(V2+C*s0*C');    s1= A*s0*A' + V1 -(A*s0*C'+V12)*k0';    k1= (A*s1*C'+V12)/(V2+C*s1*C');    dd=max(max(abs(k1-k0)));    it=it+1;    s0=s1;  end;  k=k1;s=s0;  if it>=maxit;     disp('WARNING: Iteration limit of 1000 reached in KFILTER.M');   end;end;


text:
function [im] = imgRead(iid,format)
% function [im] = imgRead(iid,format)

if nargin<2, format='color'; end

im = double(imread(imgFilename(iid))) / 255;

if strcmp(format,'gray'),
  im = rgb2gray(im);
end

author: Cloud-CV

repo: object-proposals


text:
% eeg_helpmenu() - Call the help file for EEGLAB menus
%
% Usage:
%   To call a menu of eeglab functions
%       >> eeg_helpmenu;
%   To open a help window with the specific called file.
%   Equivalent to calling >> pophelp( 'filename' );
%        >> eeg_helpmenu( 'filename' );
%
% Author: Arnaud Delorme CNL / Salk Institute 2001
%
% See also: eeglab()

% Copyright (C) 2001 Arnaud Delorme Salk Institute arno@salk.edu
%
% This program 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 2 of the License or
% (at your option) any later version.
%
% This program 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 program; if not write to the Free Software
% Foundation Inc. 59 Temple Place Suite 330 Boston MA  02111-1307  USA

function eeg_helpmenu( filename );

allmenus = { ...
'File' ''      ...
'   Import data' ''  ...
'      From ASCII/float file or Matlab array' 'pop_importdata'     ... %       Import Matlab data array
'      From continuous or seg. EGI .RAW file' 'pop_readegi'        ... %       Read continuous or seg. .EGI or .RAW datafile
'      From Multiple seg. EGI .RAW files'     'pop_readsegegi'     ... %       Read multiple seg. .EGI or .RAW datafile
'      From BCI2000 ASCII file'               'pop_loadbci'        ... %       Read .BCI datafile (Snapmaster)
'      From Snapmaster .SMA file'             'pop_snapread'       ... %       Read .SMA datafile (Snapmaster)
'      From Neuroscan .CNT file'              'pop_loadcnt'        ... %       Read .CNT datafile (Neuroscan continuous)
'      From Neuroscan .EEG file'              'pop_loadeeg'        ... %       Read .EEG datafile (Neuroscan epochs)
'      From Biosemi .BDF file'                'pop_biosig'         ... %       Read .BDF datafile
'      From .EDF file'                        'pop_biosig'         ... %       Read .EDF datafile
'      From ANT EEProbe .CNT file'            'pop_loadeep'        ... %       Read .CNT datafile (ANT EEProbe)
'      From ANT EEProbe .AVR file'            'pop_loadeep_avg'    ... %       Read .AVR datafile (ANT EEProbe)
'      From .BDF file (backup function)'      'pop_readbdf'        ... %       Read .BDF datafile
'      From Brain Vis. Rec. .VHDR file'       'pop_loadbv'         ... %       Read .VHDR datafile (Brain Vision Rec.)
'      From Brain Vis. Anal. Matlab file'     'pop_loadbva'        ... %       Read Matlab datafile (Brain Vision Analysis)
'      From CTF Folder (MEG)'                 'ctf_folder'         ... %       Import MEG datafiles from chosen CTF folder.
'      From ERPSS .RAW or .RDF file'          'pop_read_erpss'     ...
'      From INStep .ASC file'                 'pop_loadascinstep'  ... %       Read .ASC datafile (INStep)
'      From 4D .M4D pdf file'                 'pop_read4d'         ... %       Read .M4D datafile (4D pdf)
'      From other formats using FILEIO'       'pop_fileio'         ... %       Import data using FILEIO
'      From other formats using BIOSIG'       'pop_biosig'         ...
'   Import epoch info' ''      ...
'      From Matlab array or ASCII file'       'pop_importepoch'    ... %       Import Matlab array or ASCII file
'      From Neuroscan .DAT file'              'pop_loaddat'        ... %       Import .DAT info file (Neuroscan epochs)
'   Import event info' ''      ...
'      From  Matlab array or ASCII file'      'pop_importevent'    ... %       Import Matlab array or ASCII file
'      From data channel'                     'pop_chanevent'      ... %       Import events from channels
'      From Presentation .LOG file'           'pop_importpres'     ... %       Import .LOG event file (Presentation)
'      From Neuroscan .EV2 file'              'pop_importev2'      ... %       Import .EV2 even file (Neuroscan)
'   Export ' '' ...
'      Data and ICA to text file'             'pop_export'         ... %       Export Data and ICA to text file
'      Weight matrix to text file'            'pop_expica'         ... %       Export weight matrix to text file
'      Inverse weight matrix to text file'    'pop_expica'         ... %       Export inverse weight matrix to text file
'      Data to EDF/BDF/GDF file'              'pop_writeeeg'       ... %       Export Data to EDF/BDF/GDF data formats
'      Write Brain Vis. exchange format file' '            '       ...
'   Load existing dataset'                    'pop_loadset'        ... %       Load dataset
'   Save current dataset'                     'pop_saveset'        ... %       Save dataset
'   Save datasets'                            'pop_saveset'        ... %       Save dataset
'   Clear dataset(s)'                         'pop_delset'         ... %       Clear dataset(s)
'   Create Study ' '' ...
'      Using all loaded datasets'             'pop_study'          ... %       Create study using currently loaded datasets
'      Browse for datasets'                   'pop_study'          ... %       Find datasets to use in Study
'   Load existing study'                      'pop_loadstudy'      ... %       Load study
'   Save current study'                       'pop_savestudy'      ... %       Save study
'   Save current study as'                    'pop_savestudy'      ... %       Save current study as
'   Clear study'                              'pop_delset'         ... %       Clear study
'   Maximize memory'                          'pop_editoptions'    ... %       Maximize memory
'   History Scripts' '' ...
'      Save dataset history script'           'pop_saveh'          ... %       Save current dataset history
'      Save session history script'           'pop_saveh'          ... %       Save current session history
'      Run Script'                            'pop_runscript'      ... %       Run History script
'   Quit' ''      ...
'Edit' ''      ...
'   Dataset info'                             'pop_editset'        ... %       Edit dataset info
'   Event fields'                             'pop_editeventfield' ... %       Edit event fields
'   Event values'                             'pop_editeventvals'  ... %       Edit event values
'   About this dataset'                       'pop_comments'       ... %       About this dataset
'   Channel locations'                        'pop_chanedit'       ... %       Edit channels
'   Select data'                              'pop_select'         ... %       Select data
'   Select data using events'                 'pop_rmdat'          ... %       Select data using events
'   Select epochs or events'                  'pop_selectevent'    ... %       Select epochs or events
'   Copy current dataset'                     'pop_copyset'        ... %       Copy current dataset
'   Append datasets'                          'pop_mergeset'       ... %       Append another dataset
'   Delete dataset(s)'                        'pop_delset'         ... %       Delete dataset(s)
'Tools' ''      ...
'   Change sampling rate'                     'pop_resample'       ... %       Change sampling rate
'   Filter the data' '' ...
'      Basic FIR filter'                      'pop_eegfilt'        ... %       Filter the data
'      Short IIR filter'                      'pop_iirfilt'        ... %       Short IIR filter
'      ERPLAB Butterworth Digital Filter'     'pop_ERPLAB_butter1' ... %       ERPLAB Butterworth filter
'      ERPLAB Polynomial Detrending'          'pop_ERPLAB_polydetrend' ... % Polynomial detrending
'   Re-referencing'                           'pop_reref'          ... %       Average reference
'   Interpolate electrodes'                   'pop_interp'         ...
'   Reject continuous data by eye'            'pop_eegplot'        ... %       Reject continuous data
'   Extract epochs'                           'pop_epoch'          ... %       Extract epochs
'   Remove baseline'                          'pop_rmbase'         ... %       Remove baseline
'   Run ICA'                                  'pop_runica'         ... %       Run ICA
'   Remove components'                        'pop_subcomp'        ... %       Remove components
'   Automatic channel rejection'              'pop_rejchan'        ... %       Reject channels
'   Automatic epoch rejection'                'pop_autorej'        ... %       Reject epochs
'   Reject data epochs' ''  ...
'      Reject data (all methods)'             'pop_rejmenu'        ... %       Reject data (all methods)
'      Reject by inspection'                  'pop_eegplot'        ... %       Reject by inspection
'      Reject extreme values'                 'pop_eegthresh'      ... %       Reject extreme values
'      Reject by linear trend/variance'       'pop_rejtrend'       ... %       Reject by linear trend/variance
'      Reject by probability'                 'pop_jointprob'      ... %       Reject by probability
'      Reject by kurtosis'                    'pop_rejkurt'        ... %       Reject by kurtosis
'      Reject by spectra'                     'pop_rejspec'        ... %       Reject by spectra
'      Reject marked epochs'                  'pop_rejepoch'       ... %       Reject labeled epochs
'   Reject using ICA' '' ...
'      Reject components by map'              'pop_selectcomps'    ... %       Reject components by map
'      Reject data (all methods)'             'pop_rejmenu'        ... %       Reject data (all methods)
'      Reject by inspection'                  'pop_eegplot'        ... %       Reject by inspection
'      Reject extreme values'                 'pop_eegthresh'      ... %       Reject extreme values
'      Reject by linear trend/variance'       'pop_rejtrend'       ... %       Reject by linear trend/variance
'      Reject by probability'                 'pop_jointprob'      ... %       Reject by probability
'      Reject by kurtosis'                    'pop_rejkurt'        ... %       Reject by kurtosis
'      Reject by spectra'                     'pop_rejspec'        ... %       Reject by spectra
'      Reject marked epochs'                  'pop_rejepoch'       ... %       Reject labeled epochs
'   Run AMICA'  ''  ...
'      Run AMICA in parallel'                 'pop_runica'         ... %       Run AMICA in parallel (plugin)
'      Run AMICA locally'                     'pop_runica'         ... %       Run AMICA locally (plugin)
'      Load AMICA component'                  'pop_loadmodout'     ... %       Load AMICA component (plugin)
'   Run CICA'                                 ''                   ...
'   Locate dipoles using DIPFIT 2.x' '' ...
'      Head model and settings'               'pop_dipfit_settings'... %       DIPFIT Plugin settings
'      Coarse fit (grid scan)'                ''                   ... %
'      Fine fit (iterative)'                  'pop_dipfit_nonlinear'... %      Fine fit (iterative)
'      Autofit (coarse fit, fine fit & plot)' ''                   ...
'      Plot component dipoles'                ''                   ...
'   Peak detection using EEG toolbox'         ''                   ...
'   FMRIB Tools' '' ...
'      FASTR: Remove FMRI gradient artifacts' 'pop_fmrib_fastr'    ... %       Remove FMRI gradient artifacts
'      Detect QRS events'                     'pop_fmrib_qrsdetect'... %       Detect QRS events
'      Remove pulse artifacts'                'pop_fmrib_pas'      ... %       Remove pulse artifacts
'   BEM4 SCCN beta'  '' ...
'      Forward Problem Solution'              'pop_forward problem_solution' ... % Not currently working
'   Locate dipoles using LORETA' '' ...
'      Export components to LORETA'           ''                   ...
'      Import dipoles from LORETA'            ''                   ...
'      Plot dipoles on LORETA head'           ''                   ...
'Plot' ''      ...
'   Channel locations' '' ...
'      By name'                               'topoplot'           ... %       Electrodes
'      By number'                             'topoplot'           ... %       Numbers
'   Channel data (scroll)'                    'pop_eegplot'        ... %       Scroll EEG data
'   Channel spectra and maps'                 'pop_spectopo'       ... %       Channel spectra and maps
'   Channel properties'                       'pop_prop'           ... %       Component properties
'   Channel ERP image'                        'pop_erpimage'       ... %       Channel ERP image
'   Channel ERPs' ''      ...
'      With scalp maps'                       'pop_timtopo'        ... %       ERP and scalp maps
'      In scalp array'                        'pop_plottopo'       ... %       ERP in scalp array
'      In rect. array'                        'pop_plotdata'       ... %       ERP in rect. array
'   ERP maps' ''      ...
'      As 2-D scalp maps'                     'pop_topoplot'       ... %       ERP scalp maps
'      As 3-D head plots'                     'pop_headplot'       ... %       ERP head plots
'   Sum/Compare ERPs'                         'pop_comperp'        ... %       Compare ERPs
'   Component activations (scroll)'           'pop_eegplot'        ... %       Scroll component activations
'   Component spectra and maps'               'pop_spectopo'       ... %       Channel spectra and maps with components
'   Component maps' ''      ...
'      As 2-D scalp maps'                     'pop_topoplot'       ... %       Component scalp maps
'      As 3-D head plots'                     'pop_headplot'       ... %       Component head plots
'   Component properties'                     'pop_prop'           ... %       Component properties
'   Component ERP image'                      'pop_erpimage'       ... %       Component ERP image
'   Component ERPs' ''      ...
'      With component maps'                   'pop_envtopo'        ... %       Largest ERP components
'      With comp. maps (compare)'             'pop_envtopo'        ... %       Largest ERP components
'      In rectangular array'                  'pop_plotdata'       ... %       Comp. ERP time courses
'   Sum/Compare comp. ERPs'                   'pop_comperp'        ... %       Compare ERPs
'   Data statistics' ''      ...
'      Channel statistics'                    'pop_signalstat'     ...
'      Component statistics'                  'pop_signalstat'     ...
'      Event statistics'                      'pop_eventstat'      ...
'   Time-frequency transforms' ''  ...
'      Channel time-frequency'                'pop_timef'          ... %       Channel time-frequency
'      Channel cross-coherence'               'pop_crossf'         ... %       Channel cross-coherence
'      Component time-frequency'              'pop_timef'          ... %       Component time-frequency EEGLAB'));
'      Component cross-coherence'             'pop_crossf'         ... %       Component cross-coherence
'   Cluster dataset ICs'                      'pop_miclust'        ... %       Cluster ICs
'Study' ''     ...
'   Edit study info'                          'pop_study'          ...
'   Precompute channel measures'              'pop_precomp'        ...
'   Plot channel measures'                    'pop_chanplot'       ...
'   Precompute component measures'            'pop_precomp'        ...
'   Build preclustering array'                'pop_preclust'       ...
'   Cluster components'                       'pop_clust'          ...
'   Edit/plot clusters'                       'pop_clustedit'      ...
'Datasets' ''   ...
'   Current/Active Datasets (listed as selectable items)' ''       ...
'   Select multiple datasets'                  ''                  ...
'   Select the study set'                      ''                  ... %      Only selectable if study is loaded
'Help' ''    ...
'   About EEGLAB'                              'eeglab'            ...
'   About EEGLAB Help'                         'eeg_helphelp'      ...
'   EEGLAB menus'                              'eeg_helpmenu'      ...
'   EEGLAB functions'                          ''                  ...
'       Toolbox functions'                     ''                  ...
'       Signal processing functions'           'eeg_helpsigproc'   ...
'       Interactive pop_functions'             'eeg_helppop'       ...
'   EEGLAB advanced'                           ''                  ...
'       Dataset structure'                     'eeg_checkset'      ...
'       Admin functions'                       'eeg_helpadmin'     ...
'   Web tutorial'                              ''                  ...
'   Email EEGLAB'                              ''                  ...

};

text  = allmenus( 1:2:length(allmenus));
command = allmenus( 2:2:length(allmenus));

for index = 1:length(command)
	if ~isempty(command{index})
		command{index} = [ 'pophelp(''' command{index} ''');' ];
	end;
end;

textgui( text, command,'fontsize', 15, 'fontname', 'times', 'linesperpage', 18, 'title',strvcat( 'Interactive (pop_) functions', '(Click on blue text for help)'));
try
	icadefs; set(gcf, 'COLOR', BACKCOLOR);
	h = findobj('parent', gcf, 'style', 'slider');
	set(h, 'backgroundcolor', GUIBACKCOLOR);
catch, end;

if nargin > 0
	close(gcf);
    pophelp(filename);
	%command = allmenus( 2:2:length(allmenus));
	%for index = 1:length(text)
	%	if isempty(allmenus{index*2})
	%		tmpparam{index} = {  '' allmenus{(index-1)*2+1} };
	%	else
	%		tmpparam{index} = {  [ allmenus{index*2} '.m' ] allmenus{(index-1)*2+1} };
	%	end;
	%end;
 	%makehtml( tmpparam, '/home/www/eeglab/allfunctions', 'outputfile', 'tempmenu.html', 'mainonly', 'on');
    %}
end;

return;

% $$$ [textmenu nblines l] = getallmenus(findobj('tag', 1) ~= 32 )
% $$$ fontsize{ index } = fontsize{ index }+1;
% $$$ fontweight{ index } ='bold';
% $$$
% $$$ fontsize(1:length( textmenu )) = { 15 }; 6) ~= 32 fontweight{ index } ='bold'; end;
% $$$ fontweight(1:length( textmenu )) = { 'normal' }; :));
% $$$ for index = 1:length( textmenu )
% $$$ if textmenu(index
% $$$ if textmenu(index
% $$$ a = deblank(textmenu(index
% $$$ if index > length( commands )
% $$$ commands = { commands{:} [] }; 1:length(a)) = a;
% $$$ end;
% $$$ if ~isempty(commands{index})
% $$$ a = [ a ' -- ' commands{index} '()'];
% $$$ textmenu(index
% $$$ commands{index} = [ ''pophelp(''' commands{index} ''');' ]; ...
% $$$ end; click on blue text below)'  ' ...
% $$$ end; :));
% $$$
% $$$ textmenu = strvcat('Functions called through the EEGLAB menu'
% $$$ (For help message
% $$$ textmenu(1:end-1 :) commands ...
% $$$ fontsize   = { 16 15 15 fontsize{:} }; fontsize fontweight' fontweight fontname' times' linesperpage' 17 );
% $$$ fontweight = { 'bold' 'normal' 'normal' fontweight{:} };
% $$$ commands   = { '' ' ' '' commands{:} };
% $$$ textgui(textmenu(1:end-1
% $$$ fontsize'
% $$$ return;

author: PatternRecognition

repo: OpenBMI


text:
function [cg,theta] = cgmo(im,radius,norient,varargin)
% function [cg] = cgmo(im,radius,norient,...)
%
% Compute the color gradient at a single scale and multiple
% orientations.
%
% INPUT
%	im		Grayscale or RGB image, values in [0,1].
%	radius		Radius of disc for cg.
%	norient		Number of orientations for cg.
%	'nbins'		Number of bins; should be > 1/sigmaSim.
%	'sigmaSim'	For color similarity function.
%	'gamma'		Gamma correction for LAB [2.5].
%	'smooth'	Smoothing method, one of
%			{'gaussian','savgol','none'}, default 'none'.
%	'sigmaSmo'	Sigma for smoothing, default to radius.
%
% OUTPUT
%	cg		Size [h,w,d,norient] array of cg images,
%			where d is the dimensionality of the image.
%
% The input parameters {radius,nbins,sigmaSim,sigmaSmo} should be
% scalars when the input image is grayscale, and can be either scalars
% or 3-element vectors when the image is RGB.
%
% See also cgmo.
%
% David R. Martin <dmartin@eecs.berkeley.edu>
% April 2003

% process options
nbins = 32;
sigmaSim = 0.1;
gamma = 2.5;
smooth = 'none';
sigmaSmo = radius;
for i = 1:2:numel(varargin),
  opt = varargin{i};
  if ~ischar(opt), error('option names not a string'); end
  if i==numel(varargin), error(sprintf('option ''%s'' has no value',opt)); end
  val = varargin{i+1};
  switch opt,
   case 'nbins', nbins=val;
   case 'sigmaSim', sigmaSim=val;
   case 'gamma', gamma=val;
   case 'smooth',
    switch val,
     case {'none','gaussian','savgol'}, smooth=val;
     otherwise, error(sprintf('invalid option smooth=''%s''',val));
    end
   case 'sigmaSmo', sigmaSmo=val;
   otherwise, error(sprintf('invalid option ''%s''',opt));
  end
end

% check arguments
if ndims(im)==2, % grayscale image
  if numel(radius)~=1, error('radius should have 1 element'); end
  if numel(nbins)~=1, error('nbins should have 1 element'); end
  if numel(sigmaSim)~=1, error('sigmaSim should have 1 element'); end
  if numel(sigmaSmo)~=1, error('sigmaSim should have 1 element'); end
elseif ndims(im)==3, % RGB image
  if numel(radius)==1, radius = radius*ones(3,1); end
  if numel(nbins)==1, nbins = nbins*ones(3,1); end
  if numel(sigmaSim)==1, sigmaSim = sigmaSim*ones(3,1); end
  if numel(sigmaSmo)==1, sigmaSmo = sigmaSmo*ones(3,1); end
  if numel(radius)~=3, error('radius should have 1 or 3 elements'); end
  if numel(nbins)~=3, error('nbins should have 1 or 3 elements'); end
  if numel(sigmaSim)~=3, error('sigmaSim should have 1 or 3 elements'); end
  if numel(sigmaSmo)~=3, error('sigmaSmo should have 1 or 3 elements'); end
  radius = radius(:);
  nbins = nbins(:);
  sigmaSim = sigmaSim(:);
  sigmaSmo = sigmaSmo(:);
else
  error('image not of valid dimension');
end
norient = max(1,norient);
nbins = max(1,nbins);

% min and max values for a,b channels of LAB
% used to scale values into the unit interval
abmin = -73;
abmax = 95;

% make sure nbins is large enough with respect to sigmaSim
if any( nbins < 1./sigmaSim ),
  warning('nbins < 1/sigmaSim is suspect');
end

% check pixel valies
if min(im(:)) < 0 | max(im(:))>1,
  error('pixel values out of range [0,1]');
end

if ndims(im)==2, % grayscale image

  % compute cg from gray values
  cmap = max(1,ceil(im*nbins));
  csim = colorsim(nbins,sigmaSim);
  [cg,theta] = tgmo(...
      cmap,nbins,radius,norient,...
      'tsim',csim,'smooth',smooth,'sigma',sigmaSmo);

else, % RGB image

  % convert gamma-corrected image to LAB and scale values into [0,1]
  lab = RGB2Lab(im.^gamma);
  lab(:,:,1) = lab(:,:,1) ./ 100;
  lab(:,:,2) = (lab(:,:,2) - abmin) ./ (abmax-abmin);
  lab(:,:,3) = (lab(:,:,3) - abmin) ./ (abmax-abmin);
  lab(:,:,2) = max(0,min(1,lab(:,:,2)));
  lab(:,:,3) = max(0,min(1,lab(:,:,3)));

  % compute cg from LAB values
  cg = zeros([size(im) norient]);
  for i = 1:3,
    cmap = max(1,ceil(lab(:,:,i)*nbins(i)));
    csim = colorsim(nbins(i),sigmaSim(i));
    [cg(:,:,i,:),theta] = tgmo(...
        cmap,nbins(i),radius(i),norient,...
        'tsim',csim,'smooth',smooth,'sigma',sigmaSmo(i));
  end

end

% compute color similarity matrix assuming colors are in [0,1]
function m = colorsim(nbins,sigma)
bc = ((1:nbins)-0.5)/nbins; % bin centers
[x,y] = meshgrid(bc,bc);
m = 1.0 - exp(-abs(x-y).^2./(2*sigma.^2));


text:
function LR = computeLR(S, dt, L, M)
%COMPUTELR   Create a contour around each eigenvalue of the linear part of a
%SPINOPERATOR.
%   LR = COMPUTELR(S, DT, L, M) outputs a matrix to be used for the complex
%   means. DT is the time-step, L is the linear part of the SPINOPERATOR S, and
%   M is the number of points to discretize the contour.

% Copyright 2017 by The University of Oxford and The Chebfun Developers.
% See http://www.chebfun.org/ for Chebfun information.

% Set-up:
dim = getDimension(S); % spatial dimension (1, 2 or 3)
nVars = S.numVars;     % number of unknown functions
N = size(L, 1)/nVars;  % grid points

% Roots of unity:
if ( isreal(L) == 1 )
    % Use only upper-half circle when eigenvalues are real:
    r = exp(1i*pi*((1:M) - .5)/M);
else
    r = exp(2i*pi*((1:M) - .5)/M);
end

% Move each root of unity around each entry of DT*L:
LR = dt*repmat(L(:), 1, M) + repmat(r, nVars*N^dim, 1);

end

author: chebfun

repo: chebfun

save_path: github-repos/MATLAB/chebfun-chebfun


text:
%Charge Neutrality Equation
%Assuming that the material contains only one type of dopant
%NA (Acceptor)
function F = neutralp(Nv,Nc,NA,Ev,Ec,Ea,Efp,k,T,gA)
F = Nv*((exp(-((Ev-Efp)/(k*T)))+3*sqrt(pi/2)*((((Ev-Efp)/(k*T))+2.13)+((abs(((Ev-Efp)/(k*T))-2.13)).^2.4+9.6).^(5/12)).^(-3/2)).^-1)-Nc*((exp(-((Efp-Ec)/(k*T)))+3*sqrt(pi/2)*((((Efp-Ec)/(k*T))+2.13)+((abs(((Efp-Ec)/(k*T))-2.13)).^2.4+9.6).^(5/12)).^(-3/2)).^-1)-(NA/(1+gA*exp((Ea-Efp)/(k*T))));


text:
function savetovariable = chipfile( compleximagefile, outfile, varargin )
%CHIPFILE Saves an AOI from a complex image to file or variable
%
%    chipfile(compleximagefile, outfile, 'PropertyName',PropertyValue,...)
%
%       Property name     Description
%       azlimits          Min and max samples in azimuth over which to
%                            compute (default = query user with GUI).  Use
%                            'full' to specify entire range.  If nothing is
%                            selected, a MATLAB GUI will be used to select
%                            an area.
%       rnglimits         Min and max lines in range over which to compute
%                            (default = query user with GUI).  Use 'full'
%                            to specify entire range.  If nothing is
%                            selected, a MATLAB GUI will be used to select
%                            an area.
%       framenumber       Frame to process if a multi-image file.  Default
%                            is 1.
%       file_format       Format of output file.  'SIO', 'SICD', or 'NRL'.
%                            Default is SICD.
%       block_size        Determines how many bytes are in memory at once.
%                            Set to Inf to read whole image at once.
%                            Default is about 50 Mbytes.
%
% Optionally one can also use this function to chip a file to a variable in
% memory:
%    savetovariable = chipfile(compleximagefile);
%
% Written by: Wade Schwartzkopf, NGA/IDT
%
% //////////////////////////////////////////
% /// CLASSIFICATION: UNCLASSIFIED       ///
% //////////////////////////////////////////

% Select input image through GUI if not provided (and save path)
if (nargin<1)||isempty(compleximagefile)
    % Recall last interactively selected path used
    if ispref('matlab_sar_toolbox','last_used_directory')
        pathname = getpref('matlab_sar_toolbox','last_used_directory');
        if ~ischar(pathname)||~exist(pathname,'dir')
            pathname = pwd;
        end
    else
        pathname = pwd;
    end
    [compleximagefile,pathname]=uigetfile(sar_file_extensions('complex'),...
        'Select Input File',pathname);
    if(~compleximagefile), return; end; % Cancel was chosen
    setpref('matlab_sar_toolbox','last_used_directory',pathname);
    compleximagefile=fullfile(pathname,compleximagefile);
else
    pathname=fileparts(which(compleximagefile));
end

% Select output image through GUI if not provided (and save path)
default_filetype = 'SICD'; % If not chosen through file GUI
if ((nargin<2)||isempty(outfile))&&(nargout==0)
    [outfile,pathname,filterindex]=uiputfile(...
        {'*.ntf','SICD (*.ntf)'; '*.sio','SIO (*.sio)'; '*.iq8','NRL (*.iq8)'},...
        'Select output filename',pathname);
    if(~outfile), return; end; % Cancel was chosen
    exts = {'SICD','SIO','NRL'};
    default_filetype = exts{filterindex};
    outfile=fullfile(pathname,outfile);
end

% Parse input parameters
p = inputParser;
p.KeepUnmatched=true;
p.addParamValue('azlimits','default');
p.addParamValue('rnglimits','default');
p.addParamValue('framenumber',1);
p.addParamValue('file_format',default_filetype);
p.addParamValue('block_size',2^26); % in bytes
p.FunctionName = mfilename;
p.parse(varargin{:});
azlimits=p.Results.azlimits;
rnglimits=p.Results.rnglimits;
framenumber=p.Results.framenumber;
if(strcmpi(azlimits,'default')&&strcmpi(rnglimits,'default'))
    [aoi_info, framenumber]=mitm_viewer(compleximagefile,'mode','aoi',...
        'closeAfterSelect',true);
    if ~isempty(aoi_info) % User may have closed viewer without selecting AOI
        azlimits=[aoi_info(1) aoi_info(1)+aoi_info(3)-1];
        rnglimits=[aoi_info(2) aoi_info(2)+aoi_info(4)-1];
    else
        savetovariable = []; return;
    end
end
reader_object=open_reader(compleximagefile);
if iscell(reader_object)
    reader_object = reader_object{framenumber};
end
meta = reader_object.get_meta();
if(isempty(azlimits)||any(strcmpi(azlimits,{'full','default'})))
    azlimits=[1 double(meta.ImageData.NumCols)];
end
if(isempty(rnglimits)||any(strcmpi(rnglimits,{'full','default'})))
    rnglimits=[1 double(meta.ImageData.NumRows)];
end
save_to_file=exist('outfile','var')&&~isempty(outfile); % Will be saving chip to file
if save_to_file
    if ~isfield(meta.ImageData, 'PixelType')
        meta.ImageData.PixelType = 'RE32F_IM32F'; % Default type
    end
    % Update SICD coordinates to reflect chip area within larger image
    meta.ImageData.NumRows = uint32(diff(rnglimits)+1);
    meta.ImageData.NumCols = uint32(diff(azlimits)+1);
    meta.ImageData.FirstRow = uint32(meta.ImageData.FirstRow + rnglimits(1) - 1);
    meta.ImageData.FirstCol = uint32(meta.ImageData.FirstCol + azlimits(1) - 1);
    meta = add_sicd_corners(meta); % Update corners coords
    switch p.Results.file_format
        case 'SIO'
            writer_object=SIOWriter(outfile, meta);
        case 'SICD'
            writer_object=SICDWriter(outfile, meta);
        case 'NRL'
            writer_object=NRLWriter(outfile, meta);
        otherwise
            % Error
    end
end
if nargout>0, savetovariable=zeros(diff(azlimits)+1,diff(rnglimits)+1); end; % Saving to variable in memory

% Do chipping
first_row_in_block=rnglimits(1);
num_rows_in_block=max(1,floor(p.Results.block_size/((diff(azlimits)+1)*8))); % Assume 8-byte elements (largest allowed in SICD)
wb_hand=waitbar(0,'Chipping data...');
while(first_row_in_block<rnglimits(2))
    row_indices=first_row_in_block:min(rnglimits(2),first_row_in_block+num_rows_in_block-1);
    image_block = reader_object.read_chip(azlimits,row_indices([1 end]));
    if nargout>0, savetovariable(:,row_indices-rnglimits(1)+1)=image_block; end;
    if save_to_file
        writer_object.write_chip(image_block, [1 (first_row_in_block-rnglimits(1)+1)]);
    end
    first_row_in_block=row_indices(end)+1;
    waitbar(double(first_row_in_block-rnglimits(1))/double(diff(rnglimits)+1),wb_hand);
end
close(wb_hand);
reader_object.close();
% writer_object will close itself upon leaving this function

% //////////////////////////////////////////
% /// CLASSIFICATION: UNCLASSIFIED       ///
% //////////////////////////////////////////

author: ngageoint


text:
function [im] = prep_im_for_blob(im, im_means, target_size, max_size)
    im = single(im);

    if ~isa(im, 'gpuArray')
        try
            im = bsxfun(@minus, im, im_means);
        catch
            im_means = imresize(im_means, [size(im, 1), size(im, 2)], 'bilinear', 'antialiasing', false);
            im = bsxfun(@minus, im, im_means);
        end
        %im_scale = prep_im_for_blob_size(size(im), target_size, max_size);

        %target_size = round([size(im, 1), size(im, 2)] * im_scale);
        im = imresize(im, target_size, 'bilinear', 'antialiasing', false);
    else
        % for im as gpuArray
        try
            im = bsxfun(@minus, im, im_means);
        catch
            im_means_scale = max(double(size(im, 1)) / size(im_means, 1), double(size(im, 2)) / size(im_means, 2));
            im_means = imresize(im_means, im_means_scale);
            y_start = floor((size(im_means, 1) - size(im, 1)) / 2) + 1;
            x_start = floor((size(im_means, 2) - size(im, 2)) / 2) + 1;
            im_means = im_means(y_start:(y_start+size(im, 1)-1), x_start:(x_start+size(im, 2)-1));
            im = bsxfun(@minus, im, im_means);
        end

        %im_scale = prep_im_for_blob_size(size(im), target_size, max_size);
        %im = imresize(im, target_size);
    end
end

author: wenguanwang

repo: deepattention


text:
function [headinfo,fid]=decode_sp3h(fid)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%read file header information
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global glc gls
type=' '; time=gls.gtime; ns=0;
sats=zeros(1,glc.MAXSAT); tsys=''; bfact=zeros(1,2);
n=0; idxns=0; idxc=0; idxf=0; idx_break=0;

while ~feof(fid)
    line=fgetl(fid);n=n+1;
    if n==1
        type=line(3);
        time=str2time(line(4:31));
    elseif strcmp(line(1),'+')
        if n==3,ns=str2double(line(3:6));end
        if idxns<ns
            j=0;
            while j<17
                sys=code2sys(line(10+3*j));
                prn=str2double(line(11+3*j:12+3*j));
                if sys==glc.SYS_QZS,prn=prn+192;end
                if idxns<=glc.MAXSAT
                    sats(idxns+1)=satno(sys,prn);
                    idxns=idxns+1;
                end
                j=j+1;
            end
        end
    elseif strcmp(line(1:2),'%c')&&idxc==0
        tsys=line(10:12);
        idxc=idxc+1;
    elseif strcmp(line(1:2),'%f')&&idxf==0
        bfact(1)=str2double(line(4:13));
        bfact(2)=str2double(line(15:26));
        idxf=idxf+1;
    elseif strcmp(line(1:2),'/*')
        idx_break=idx_break+1;
        if idx_break==4
            break;
        end
    end

end

headinfo.type=type;
headinfo.time=time;
headinfo.ns=ns;
headinfo.sats=sats;
headinfo.tsys=tsys;
headinfo.bfact=bfact;

return

repo: GINav


text:
function [rsvn,rsvp,rsvnSS,rsvpSS]=realized_semivariance(price,time,timeType,samplingType,samplingInterval,subsamples)
% Estimates Realized Semivariance and subsampled Realized Semivariance
%
% USAGE:
%   [RSVN,RSVP,RSVNSS,RSVPSS] = realized_semivariance(PRICE,TIME,TIMETYPE,SAMPLINGTYPE,SAMPLINGINTERVAL,SUBSAMPLES)
%
% INPUTS:
%   PRICE            - m by 1 vector of high frequency prices
%   TIME             - m by 1 vector of times where TIME(i) corresponds to PRICE(i)
%   TIMETYPE         - String describing the way times are measured
%                       'wall'    24-hour clock of the form HHMMSS, e.g. 101543 or 153217
%                       'seconds' Time measured in seconds past midnight on the first day.
%                       'unit'  Unit normalized date format, e.g. .1, .234, .9
%                         Unit normalized times are more general than the other types and can be
%                         applied to data from more than one calendar day
%   SAMPLINGTYPE     - String describing the type of sampling to use when
%                        filtering PRICE
%                        'CalendarTime' - Sample in calendar time using observations separated by SAMPLINGINTERVAL seconds
%                        'CalendarUniform' - Sample in calendar time using SAMPLINGINTERVAL
%                          observations spread uniformly between TIME(1) and TIME(m)
%                        'BusinessTime' - Sample in business (tick) time using observation separated
%                          by SAMPLINGINTERVAL ticks
%                        'BusinessUniform' - Sample in business (tick) time using observations
%                          uniformly spaced in business time.
%                        'Fixed' - Sample at specific points in time. When using fixed,
%                          SAMPLINGINTERVAL must be a n by 1 vector of times with the same TIMETYPE
%                          as TIME (i.e. seconds if TIME is in seconds)
%   SAMPLINGINTERVAL  - Scalar integer or n by 1 vector whose meaning depends on the selected SAMPLINGTYPE
%   SUBSAMPLES        - [OPTIONAL] Scalar integer indicating the number of subsample realized
%                         semivariance estimators to average with the original realized semivariance.
%                         Subsample realized semivariances are based on prices uniformly spaced between
%                         the times (Calendar sampling) or ticks (Business sampling).  SUBSAMPLES=1
%                         will compute a subsample realized semivariance using the mid-point of the
%                         price sample points, 2 will use 1/3 and 2/3, and so on. In general this
%                         number should be small so the subsample estimators will be "sparse".
%
% OUTPUTS:
%   RSVN              - Negative-part realized semivariance estimate
%   RSVP              - Positive-part realized semivariance estimate
%   RSVNSS            - Subsample averaged negative-part realized semivariance estimate
%   RSVPSS            - Subsample averaged positive-part realized semivariance estimate
%
% COMMENTS:
%
% EXAMPLES:
%  % 5-minute realized semivariance using wall time returns and fixed increments
%  fixedInterval = seconds2wall(wall2seconds(93000):300:wall2seconds(160000));
%  [RSVN,RSVP] = realized_semivariance(PRICE,TIME,'wall','Fixed',fixedInterval)
%
%  % 10-tick realized semivariance
%  [RSVN,RSVP] = realized_semivariance(PRICE,TIME,'wall','BusinessTime',10)
%
%  % 5-minute realized semivariance with subsampling every minute
%  fixedInterval = seconds2wall(wall2seconds(93000):300:wall2seconds(160000));
%  [RSVN,RSVP,RSVNSS,RSVPSS] = realized_semivariance(PRICE,TIME,'wall','Fixed',fixedInterval,5)
%
%  See also REALIZED_VARIANCE, REALIZED_KERNEL, REALIZED_QUANTILE_VARIANCE, REALIZED_RANGE,
%  REALIZED_PRICE_FILTER

% Copyright: Kevin Sheppard
% kevin.sheppard@economics.ox.ac.uk
% Revision: 1    Date: 5/1/2008

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Checking
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin<5 || nargin>6
    error('Five or Six inputs required.')
end
if size(price,2)>size(price,1)
    price=price';
end
if size(price,2)>1
    error('PRICE must be a m by 1 vector.')
end
if size(time,2)>size(time,1)
    time=time';
end
if any(diff(time)<0)
    error('TIME must be sorted and increasing')
end
if size(time,2)>1 || length(time)~=length(price)
    error('TIME must be a m by 1 vector.')
end
% Inserted to protect against inputing integer times
time = double(time);

timeType=lower(timeType);
if ~ismember(timeType,{'wall','seconds','unit'})
    error('TIMETYPE must be one of ''wall'', ''seconds'' or ''unit''.');
end
samplingType=lower(samplingType);
if ~ismember(samplingType,{'calendartime','calendaruniform','businesstime','businessuniform','fixed'})
    error('SAMPLINGTYPE must be one of ''CalendarTime'', ''CalendarUniform'', ''BusinessTime'', ''BusinessUniform'' or ''Fixed''.');
end

m=size(price,1);
t0=time(1);
tT=time(m);
if ismember(samplingType,{'calendartime','calendaruniform','businesstime','businessuniform'})
    % Must be a scalar integer if timeType is seconds or wall
    if ismember(timeType,{'wall','seconds'})
        if ~isscalar(samplingInterval) || floor(samplingInterval)~=samplingInterval || samplingInterval<1
            error('SAMPLINGINTERVAL must be a positive integer for the SAMPLINGTYPE selected when using ''wall'' or ''seconds'' as TIMETYPE.')
        end
    else
        if ~isscalar(samplingInterval) || samplingInterval<0
            error('SAMPLINGINTERVAL must be a positive value for the SAMPLINGTYPE selected when using ''unit'' as TIMETYPE.')
        end
    end
else
    if size(samplingInterval,2)>size(samplingInterval,1)
        samplingInterval=samplingInterval';
    end
    if ~(any(samplingInterval>=t0) && any(samplingInterval<=tT))
        error('At least one sampling interval must be between min(TIME) and max(TIME) when using ''Fixed'' as SAMPLINGTYPE.')
    end
    if any(diff(samplingInterval)<=0)
        error('When using ''Fixed'' as SAMPLINGTYPE the vector of sampling times in SAMPLINGINTERVAL must be sorted and strictly increasing.')
    end
end

if nargin<6 || isempty(subsamples)
    subsamples = 1;
end
if nargin==6 && ~isempty(subsamples)
    if ~isscalar(subsamples) || subsamples<0 || floor(subsamples)~=subsamples
        error('SUBSAMPLES must be a non-negative scalar.')
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Checking
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Convert times to unit if not already unit
if ~strcmp(timeType,'unit')
    [time,~,~,samplingInterval]=realized_convert2unit(time,timeType,samplingType,samplingInterval);
end
% Since everything is converted to unit, set timeType to unit
timeType='unit';

% Filter prices and compute the RV
logPrice = log(price);
filteredLogPrice = realized_price_filter(logPrice,time,timeType,samplingType,samplingInterval);
returns = diff(filteredLogPrice);
rsvn=sum((returns.^2).*(returns<0));
rsvp=sum((returns.^2).*(returns>0));

subsampledLogPrices = realized_subsample(logPrice,time,timeType,samplingType,samplingInterval,subsamples);
rsvns = zeros(subsamples,1);
rsvps = zeros(subsamples,1);
totalCount = 0;
for i=1:subsamples
    returns = diff(subsampledLogPrices{i});
    rsvns(i) = sum((returns.^2).*(returns<0));
    rsvps(i) = sum((returns.^2).*(returns>0));
     if i==1
        baseCount = length(returns);
    end
    totalCount = totalCount + length(returns);
end
rsvnSS = sum(rsvns)  * (baseCount / totalCount);
rsvpSS = sum(rsvps)  * (baseCount / totalCount);

author: bashtage

repo: mfe-toolbox