Mercurial > repos > public > sbplib
diff spdiagsVariablePeriodic.m @ 800:87ea9cac3287 feature/poroelastic
Make spdiagVariable a local functions
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 26 Jul 2018 17:53:51 -0700 |
parents | 8c65ef13df89 |
children |
line wrap: on
line diff
--- a/spdiagsVariablePeriodic.m Thu Jul 26 17:51:48 2018 -0700 +++ b/spdiagsVariablePeriodic.m Thu Jul 26 17:53:51 2018 -0700 @@ -39,4 +39,22 @@ end -end \ No newline at end of file +end + +function A = spdiagVariable(a,i) + default_arg('i',0); + + if isrow(a) + a = a'; + end + + n = length(a)+abs(i); + + if i > 0 + a = [sparse(i,1); a]; + elseif i < 0 + a = [a; sparse(abs(i),1)]; + end + + A = spdiags(a,i,n,n); +end