{"action":"created","issue":{"url":"https://api.github.com/repos/chebfun/chebfun/issues/1542","labels_url":"https://api.github.com/repos/chebfun/chebfun/issues/1542/labels{/name}","comments_url":"https://api.github.com/repos/chebfun/chebfun/issues/1542/comments","events_url":"https://api.github.com/repos/chebfun/chebfun/issues/1542/events","html_url":"https://github.com/chebfun/chebfun/issues/1542","id":89563353,"number":1542,"title":"Why is chebtech/qr not done like this? ","user":{"login":"ajt60gaibb","id":1814063,"avatar_url":"https://avatars.githubusercontent.com/u/1814063?v=3","gravatar_id":"","url":"https://api.github.com/users/ajt60gaibb","html_url":"https://github.com/ajt60gaibb","followers_url":"https://api.github.com/users/ajt60gaibb/followers","following_url":"https://api.github.com/users/ajt60gaibb/following{/other_user}","gists_url":"https://api.github.com/users/ajt60gaibb/gists{/gist_id}","starred_url":"https://api.github.com/users/ajt60gaibb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajt60gaibb/subscriptions","organizations_url":"https://api.github.com/users/ajt60gaibb/orgs","repos_url":"https://api.github.com/users/ajt60gaibb/repos","events_url":"https://api.github.com/users/ajt60gaibb/events{/privacy}","received_events_url":"https://api.github.com/users/ajt60gaibb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chebfun/chebfun/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-19T13:20:10Z","updated_at":"2015-06-19T14:48:18Z","closed_at":null,"body":"Hi @nickhale and @trefethen,\r\n\r\nIs this a viable way to do `qr()` in `chebtech`?   On my machine it is x2 slower than the `chebtech2/qr()`, but with a bit of Nick Hale magic that could change.  It is certainly a simple approach. \r\n\r\nIdea:  Use the Legendre basis to relate the continuous QR to the discrete QR. Then, use discrete `qr()`.\r\n\r\n```\r\nfunction [Q, R] = myqr( A )\r\nchebA = cheb2leg( A.coeffs );               % Get Legendre coefficients of array-valued chebtech\r\nD = diag( 1./sqrt((0:size(legA, 1)-1)+.5) );% Orthonormalization constants.\r\n[ Qleg, R ] = qr( D*legA, 0);               % Discrete QR\r\nQ = chebtech2( { [], leg2cheb( D\\Qleg ) } );% Construct continuous QR\r\nDs = diag( sign( diag( R ) ) );             % Ensure diagonals of R are of +ve sign.\r\nR = Ds * R; Q = Q * Ds;\r\nend\r\n```\r\n\r\nYou can check that it computes the right thing with this code: \r\n```\r\nA = chebtech2(@(x) [cos(100*x.^2), sin(100*x)]); \r\n[Qexact, Rexact] = qr( A );\r\n[Q, R] = myqr( A ); \r\nnormest( A - Q * R )\r\nnormest(Q - Qexact)\r\nnormest(R - Rexact)\r\n```"},"comment":{"url":"https://api.github.com/repos/chebfun/chebfun/issues/comments/113536101","html_url":"https://github.com/chebfun/chebfun/issues/1542#issuecomment-113536101","issue_url":"https://api.github.com/repos/chebfun/chebfun/issues/1542","id":113536101,"user":{"login":"nickhale","id":2035010,"avatar_url":"https://avatars.githubusercontent.com/u/2035010?v=3","gravatar_id":"","url":"https://api.github.com/users/nickhale","html_url":"https://github.com/nickhale","followers_url":"https://api.github.com/users/nickhale/followers","following_url":"https://api.github.com/users/nickhale/following{/other_user}","gists_url":"https://api.github.com/users/nickhale/gists{/gist_id}","starred_url":"https://api.github.com/users/nickhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickhale/subscriptions","organizations_url":"https://api.github.com/users/nickhale/orgs","repos_url":"https://api.github.com/users/nickhale/repos","events_url":"https://api.github.com/users/nickhale/events{/privacy}","received_events_url":"https://api.github.com/users/nickhale/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T14:48:18Z","updated_at":"2015-06-19T14:48:18Z","body":"If you get rid of the fluff then the existing approach is also just a couple of lines. \r\n\r\nThe code could be the same for the values approach also, but we don't do so in order to take advantage of caching (which is mostly for the benefit of Chebfun2)."}}