bugGNU Octave - Bugs: bug #55280, Support arbitrary unicode...

 
 

bug #55280: Support arbitrary unicode characters in comments

Submitter:  None
Submitted:  Tue 25 Dec 2018 02:37:05 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Other
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  334699 Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.2.2
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 25 Dec 2018 03:32:41 PM UTC, comment #3: 

Just a small addition. Block comments in Octave are perfectly fine, see https://octave.org/doc/v4.2.2/Block-Comments.html.

In your case the delimiter must be exclusively in that line.  For example:


#{
Blah blah blah
#}


but NOT:


#{ Blah blah blah
#}



Kai Torben Ohlhus <siko1056>
Group Member
Tue 25 Dec 2018 03:27:26 PM UTC, comment #2: 

No problem, enjoy using Octave ;-)

Kai Torben Ohlhus <siko1056>
Group Member
Tue 25 Dec 2018 02:50:40 PM UTC, comment #1: 

Turns out I was an idiot. I'm sorry, please close this report as invalid.

I thought #{ and }# could be used for block comments.

Instead, if I remove the {'s and put # before each comment, all unicode characters work:


  # 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ₙ  │
  #  └─                                                            ─┘ └─  ─┘ └─  ─┘


On the other hand, my previous "comment" produces syntax errors even if I remove all non-ascii characters.

Sorry again for wasting your time.

Anonymous
Tue 25 Dec 2018 02:37:05 PM UTC, original submission:  

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?

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-25 siko1056 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        Item GroupFeature Request Other
        StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code