Commit 033ec538 authored by Jakob Gabriel's avatar Jakob Gabriel
Browse files

fixed #37 + also added methods for quantity.Symbolic and unittests

parent b002148b
......@@ -1860,7 +1860,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
% Complex results are produced if X is not positive.
y = quantity.Discrete(log10(obj.on()), obj(1).domain, ...
'name', "log10(" + obj(1).name + ")");
end % log()
end % log10()
function xNorm = l2norm(obj, integralGridName, optArg)
% calculates the l2 norm, for instance
......
......@@ -666,6 +666,22 @@ classdef Symbolic < quantity.Function
'name', "expm(" + obj(1).name + ")");
end % expm()
function y = log(obj)
% log Natural logarithm.
% log(X) is the natural logarithm of the elements of X.
% Complex results are produced if X is not positive.
y = quantity.Symbolic(log(obj.sym()), obj(1).domain, ...
'name', "log(" + obj(1).name + ")");
end % log()
function y = log10(obj)
% log10 Common (base 10) logarithm.
% log10(X) is the base 10 logarithm of the elements of X.
% Complex results are produced if X is not positive.
y = quantity.Symbolic(log10(obj.sym()), obj(1).domain, ...
'name', "log10(" + obj(1).name + ")");
end % log10()
function y = ctranspose(obj)
% ctranspose() or ' is the complex conjugate tranpose
y = quantity.Symbolic(conj(obj.sym().'), obj(1).domain, ...
......
......@@ -12,8 +12,22 @@ testCase.TestData.sym.t = t;
testCase.TestData.sym.sy = sy;
end
function powerTest(testCase)
function testLog(tc)
z = quantity.Domain("z", linspace(0, 1, 11));
quan = Discrete(z) * ones(2, 2) + [1, 1; 0, 0]+0.1*ones(2,2);
tc.verifyEqual(log(quan.on()), on(log(quan)), 'AbsTol', 1e-15);
tc.verifyEqual(on(quan), on(log(exp(quan))), 'AbsTol', 1e-15);
end % testLog()
function testLog10(tc)
z = quantity.Domain("z", linspace(0, 1, 11));
quan = Discrete(z) * ones(2, 2) + [1, 1; 0, 0]+0.1*ones(2,2);
tc.verifyEqual(log10(quan.on()), on(log10(quan)), 'AbsTol', 1e-15);
end % testLog10()
function powerTest(testCase)
t = quantity.Domain("t", linspace(0,1));
p(1,1) = Discrete(t);
......
......@@ -4,6 +4,21 @@ function [tests ] = testSymbolic()
tests = functiontests(localfunctions());
end
function testLog(tc)
z = quantity.Domain("z", linspace(0, 1, 11));
quan = Symbolic(z) * ones(2, 2) + [1, 1; 0, 0]+0.1*ones(2,2);
tc.verifyEqual(log(quan.on()), on(log(quan)), 'AbsTol', 1e-15);
tc.verifyEqual(on(quan), on(log(exp(quan))), 'AbsTol', 1e-15);
end % testLog()
function testLog10(tc)
z = quantity.Domain("z", linspace(0, 1, 11));
quan = Symbolic(z) * ones(2, 2) + [1, 1; 0, 0]+0.1*ones(2,2);
tc.verifyEqual(log10(quan.on()), on(log10(quan)), 'AbsTol', 1e-15);
end % testLog10()
function testDet(tc)
z = quantity.Domain("z", linspace(0, 1, 11));
zSymbolic = quantity.Symbolic(sym("z"), z);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment