Skip to content

Instantly share code, notes, and snippets.

View tholden's full-sized avatar

Tom Holden tholden

View GitHub Profile
% Derived from https://raw.githubusercontent.com/Coloquinte/stackexchange-fun/master/solver.py
% See also https://or.stackexchange.com/questions/5183/pava-like-solution-to-simple-qp
% Find X with minimal change such that L <= X <= U.
function X = FindBoundedMinChangePath( L, U )
n = numel( L );
assert( numel( U ) == n );
assert( all( L <= U ) );
function result = LogLin( VarEndoNames, VarExoNames, Parameters, Equations, SolveMode, EvalMode, EvalString, Digits )
% ------------------------------------------------------------
% PURPOSE: Performs log-linearisation.
% ------------------------------------------------------------
% SYNTAX: result = LogLin( VarEndoNames, VarExoNames, Parameters, Equations, SolveMode, EvalMode, EvalString, Digits );
% ------------------------------------------------------------
% EXAMPLE: result = LogLin( { 'R', 'A' }, { 'EPSILON' }, { 'beta', 'rho' }, { 'beta * R * A / A(+1) = 1', 'A = A(-1) ^ rho * exp( EPSILON )' }, 2, 2 )
% ------------------------------------------------------------
% OUTPUT: result: a cell array of log-linearised equations, with __d appended to variable names that are deviations from steady state.
% ------------------------------------------------------------
@tholden
tholden / NearestKroneckerProduct.m
Last active December 29, 2023 11:11
Matlab Code for finding the nearest Kronecker product to a matrix
function [ B, C, D ] = NearestKroneckerProduct( A, SizeB, SizeC, Hermitian ) %#codegen
% https://doi.org/10.1007/978-94-015-8196-7_17
m = size( A, 1 );
n = size( A, 2 );
m1 = SizeB( 1 );
n1 = SizeB( 2 );
m2 = SizeC( 1 );
n2 = SizeC( 2 );
if nargin < 4
/**
* Advanced Window Snap
* Snaps the Active Window to one of nine different window positions.
*
* @author Andrew Moore <andrew+github@awmoore.com>
* @version 1.0
*/
/**
* SnapActiveWindow resizes and moves (snaps) the active window to a given position.