octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55280] Support arbitrary unicode characters i


From: anonymous
Subject: [Octave-bug-tracker] [bug #55280] Support arbitrary unicode characters in comments
Date: Tue, 25 Dec 2018 09:37:06 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0

URL:
  <https://savannah.gnu.org/bugs/?55280>

                 Summary: Support arbitrary unicode characters in comments
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Tue 25 Dec 2018 02:37:05 PM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Feature Request
                  Status: None
             Assigned to: None
         Originator Name: 334699
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.2
        Operating System: GNU/Linux

    _______________________________________________________

Details:

Example and use case:


function pp = hspline(x,y,z)
  
  # hspline - compute hermite cubic spline
  # usage: hspline(x,y,z)
  # where x: a vector of knots in ascending orderfields
  # y: a vector of values in these knots
  # z: a vector of values of the first derivative in these knots
  # returned value: suitable to be passed to ppval
  
  if (nargin != 3 || !isvector(x) || !isvector(y) || !isvector(z))
    error("hspline: expecting 3 vectors as arguments")
  elseif (length(x) != length(y) || length(x) != length(z) || length(y) !=
length(z))
    error("hspline: expecting vectors of equal length")
  elseif (length(unique(x)) != length(x))
    error("hspline: expecting unique knots")
  endif
  
  x=x(:); y=y(:); z=z(:);
  
  if (!issorted(x))
    warning("hspline: knots are not sorted")
    S = sortrows([x,y,z],[1]);
    x=S(:,1); y=S(:,2); z=S(:,3);
  endif
  
  #{ Współczynniki wielomianów składających się na splajn wyznaczamy za
pomocą układu równań:
    ┌─                                                            ─┐
┌─  ─┐ ┌─  ─┐
    │ x₁³  x₁²  x₁  1                                             
│ │a₁  │ │y₁  │
    │3x₁² 2x₁  1                                                   │
│b₁  │ │z₁  │
    │ x₂³  x₂²  x₂  1                                             
│ │c₁  │ │y₂  │
    │3x₂² 2x₂  1                                                   │
│d₁  │ │z₂  │
    │                     x₂³  x₂²  x₂  1                         
│ │a₂  │ │y₂  │
    │                    3x₂² 2x₂  1                               │
│b₂  │ │z₂  │
    │                     x₃³  x₃²  x₃  1                         
│ │c₂  │=│y₃  │
    │                    3x₃² 2x₃  1                               │
│d₂  │ │z₃  │
    │                                       ⋱                     │
│⋮  │ │⋮  │
    │                                         xₙ₋₁³  xₙ₋₁² 
xₙ₋₁  1│ │aₙ₋₁│ │yₙ₋₁│
    │                                        3xₙ₋₁² 2xₙ₋₁  1   
   │ │bₙ₋₁│ │zₙ₋₁│
    │                                         xₙ³    xₙ²    xₙ   
1│ │cₙ₋₁│ │yₙ  │
    │                                        3xₙ²   2xₙ    1       │
│dₙ₋₁│ │zₙ  │
    └─                                                            ─┘
└─  ─┘ └─  ─┘
  #}
  
  #Najpierw żmudnie konstruujemy macierz współczynników tego układu:
  A = AA =
kron(diag(x),eye(2))(2:end-1,2:end-1)*kron(eye(length(x)-1),ones(2,1));
  
  A = kron(A,[1,1,1,0]);
  A(:,1:4:end).^=3; A(:,2:4:end).^=2;
  A = kron(A, [1,0]');
  
  AA = kron(AA,[1,1,0,0]);
  AA(:,1:4:end).^=2; AA(:,1:4:end).*=3; AA(:,2:4:end).*=2;
  AA = kron(AA, [0,1]');
  
  A = A + AA;
  A += kron(eye(length(x)-1), [0,0,0,1;0,0,1,0;0,0,0,1;0,0,1,0]);
  
  # Wektor wyrazów wolnych jest już wyraźnie prostszy:
  B = (kron(y, [1;0;1;0]) + kron(z, [0;1;0;1]))(3:end-2);
  
  # Wreszcie rozwiązujemy układ, otrzymując wektor niewiadomych:
  X = A\B;
  
  pp = mkpp(x, A\B);
endfunction


Trying to use the above piece of code results in errors:


>> hspline([1,2,3,4], [1,2,3,4], [1,2,3,4])
parse error near line 27 of file /home/m/szkolne/numeryka/oct/hspline.m

  syntax error

>>>     ┌─                                                           
─┐ ┌─  ─┐ ┌─  ─┐
        ^


Having removed block drawing characters, we see that subscripts and
superscripts also cause similar errors:


>> hspline([1,2,3,4], [1,2,3,4], [1,2,3,4])
parse error near line 28 of file /home/m/szkolne/numeryka/oct/hspline.m

  syntax error

>>>       x₁³  x₁²  x₁  1                                             
   a₁     y₁
           ^


I think supporting these kinds of characters would be useful for the reason
that it might make sense to draw a matrix in comments to better explain the
used algorithm. Besides, as this code snippet also shows, you already support
diacritics (the parser doesn't bark at ż, ó, ł), so why not support other
unicodes as well?




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55280>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]