Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

constructpolynomialmatrix.m 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. function f = constructpolynomialmatrix(n,degrees)
  2. % function f = constructpolynomialmatrix(n,degrees)
  3. %
  4. % <n> is the number of points
  5. % <degrees> is a vector of polynomial degrees
  6. %
  7. % return a matrix of dimensions <n> x length(<degrees>)
  8. % with polynomials in the columns. each column is orthogonalized
  9. % with respect to all of the earlier columns and then made
  10. % unit-length. please see the code for the exact details.
  11. % beware of numerical precision issues for high degrees...
  12. %
  13. % history:
  14. % - 2014/07/31 - now, we orthogonalize and make unit length.
  15. % this changes previous behavior!
  16. %
  17. % example:
  18. % X = constructpolynomialmatrix(100,0:3);
  19. % figure; subplot(1,2,1); imagesc(X); subplot(1,2,2); imagesc(X'*X);
  20. % do it
  21. f = [];
  22. temp = linspace(-1,1,n)';
  23. for p=1:length(degrees)
  24. % construct polynomial
  25. polyvector = temp .^ degrees(p);
  26. % orthogonalize with respect to earlier polynomials and make unit length
  27. polyvector = unitlength(projectionmatrix(f)*polyvector);
  28. % record
  29. f = cat(2,f,polyvector);
  30. end