Octave

1 program Added 2026-02-06T12:00:00Z Agent: claude-codeModel: sonnetWebSearch: disabled Evidence Report issue View issues
Aliases: GNU Octave
Provenance: commit be17780cfb · authored 2026-02-06T09:35:14+01:00 · agent claude-code · model sonnet

Sources mentioning this language

5 sources · pl_id: pl/octave
LLM (this repo) · 1PldbPygmentsWikipediaWikidata · Q20870787

Extensions claimed by this language

2 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.mpygmentsprimary52.6M files
.mwikidataprimary52.6M files

Related languages

GNU Octave (0.73)Poke (0.26)GNU Poke (0.20)GNU Guile (0.19)Bison (0.14)

Real programs from Software Heritage

7 samples mined from derived_datasets/<date>/contents/*.parquet, byte-verified against the SWH archive. Citation-grade qualified SWHIDs preserved.
cosd.m · 1575 B · ext .m · SWH occurrences unknown
via swh_study:m (judge:claude-sonnet-4.6; judge:gemini-3.8-flash; human:mathieu-acher)
swh:1:cnt:b462101dba6df91b186956e01337c58ec5962df7;origin=https://github.com/mtmiller/octave;path=/scripts/elfun/cosd.m
Open in SWH · Raw bytes (SWH)
Reviews (1 human, 2 LLM)
Ground truth · how?
👤 mathieu-acher → pl/octave (high) 2026-10-02
https://github.com/mtmiller/octave
🤖 anthropic-claude-sonnet-4.6 m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave (uses ## comments, endfunction, !=)
🤖 google-gemini-3.8-flash m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave
Show source
########################################################################
##
## Copyright (C) 2006-2020 The Octave Project Developers
##
## See the file COPYRIGHT.md in the top-level directory of this
## distribution or <https://octave.org/copyright/>.
##
## This file is part of Octave.
##
## Octave is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <https://www.gnu.org/licenses/>.
##
########################################################################

## -*- texinfo -*-
## @deftypefn {} {} cosd (@var{x})
## Compute the cosine for each element of @var{x} in degrees.
##
## Returns zero for elements where @code{(@var{x}-90)/180} is an integer.
## @seealso{acosd, cos}
## @end deftypefn

function y = cosd (x)

  if (nargin != 1)
    print_usage ();
  endif

  I = x / 180;
  y = cos (I .* pi);
  I += 0.5;
  y(I == fix (I) & isfinite (I)) = 0;

endfunction


%!assert (cosd (0:10:80), cos (pi*[0:10:80]/180), -10*eps)
%!assert (cosd ([0, 180, 360]) != 0)
%!assert (cosd ([90, 270]) == 0)

%!error cosd ()
script.m · 1279 B · ext .m · SWH occurrences unknown
via swh_study:m (judge:claude-sonnet-4.6; judge:gemini-3.8-flash)
swh:1:cnt:df59182e0ffaf2da3a22de6f32151eb5e64a8682;origin=https://github.com/Arsakes/NLSE_solver;path=/octave_scripts/script.m
Open in SWH · Raw bytes (SWH)
Reviews (2 LLM)
Ground truth · how?
🤖 anthropic-claude-sonnet-4.6 m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave (uses # comments, stdnormal_rnd, shading with string arg)
🤖 google-gemini-3.8-flash m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave
Show source
#%skrypt octave odpalający program
half_size= 1024;
xstep = 0.05;
#%stałe fizyczne

h_bar=0.658211915;
g_c=0.006;
g_r=2.0*g_c;
lam_c=0.33;
lam_r=1.5*lam_c;
R=0.00000160022;
m=0.040685;
#%szerokość próbki
d=10.0;
a=1.0/(d*2.0*pi);

#%przepisanie stałych
physical_constants=[h_bar, a*g_c, a*g_r, lam_c, lam_r, m, a*R, xstep, 0.005];
#%potencjał

V=complex(zeros(1,half_size*2.0));
X=linspace(- half_size*xstep, (half_size-1)*xstep, half_size * 2);
#% tutaj PSI jest guassem PSI=complex(exp(-X.^2));
#%PSI = soliton(X,0.0,0.0);
n_r=real(zeros(1,half_size*2));
P_l=real(exp(-X.^2));
time_steps=linspace(0.0,0.1 , 16);
rnd=stdnormal_rnd(half_size*2,1) * 0.1;
PSI=complex(rnd, rnd);

%wypluwanie wyników
[PSI_wynik, NR_wynik]=NLS_solver(PSI,V, n_r, P_l,time_steps, physical_constants );
[xx,yy]=meshgrid(time_steps, X);
#%pierwszy wykres
subplot(2,1,1)
pcolor(xx,yy,abs(PSI_wynik) ), shading("interp");
axis([0, max(time_steps) ,-(half_size)*xstep*0.5, (half_size -1)*xstep*0.5]);
colormap(hot)
title('wave function evolution')
#%plot(X, abs(PSI_wynik));
#%axis([-half_size*xstep, (half_size -1)*xstep]);
subplot(2,1,2)
pcolor(xx,yy,NR_wynik);
axis([0, max(time_steps) ,-(half_size)*xstep*0.5, (half_size -1)*xstep*0.5]);
title('reservoir polariton density')

size(PSI_wynik)

finalODEV.m · 2284 B · ext .m · SWH occurrences unknown
via swh_study:m (judge:claude-sonnet-4.6; judge:gemini-3.8-flash)
swh:1:cnt:95945dcd3b630875bdb0ab2865165abe04d3a098;origin=https://github.com/isml/il_ilce_Json;path=/BMOK_ODEV_KODLAR/finalODEV.m
Open in SWH · Raw bytes (SWH)
Reviews (2 LLM)
Ground truth · how?
🤖 anthropic-claude-sonnet-4.6 m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave (uses # comments and size(x)(dim) indexing)
🤖 google-gemini-3.8-flash m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave
Show source
clear all;
FG =imread("C:/Users/ismail/Desktop/d/1.jpg");
BG =imread("C:/Users/ismail/Desktop/d/bg1.jpg");
#ON YUZ FOTOGRAFI VE ARKA PLAN FOTOGRAFINI ?MREAD ?LE OKUNDU[1-2]
FGhsv = rgb2hsv(FG);
#ON YUZ FOTOGRAFI HSV RENK UZAYINA DÖNÜ?TÜRÜLDÜ[5]
sat = size(FGhsv)(1);
sut = size(FGhsv)(2);
#SATIR VE SUTUN B?LG?LER? KAYDED?LD?[7-8]
H=uint8(255*FGhsv(:,:,1));
S=uint8(255*FGhsv(:,:,1));
V=uint8(255*FGhsv(:,:,1));
#HSV ON YUZ FOTOGRAFININ HUE,SATURATION VE VALUE KATMANLARI KAYDED?LD?[10-12]
hueMask = (H >= 70) & (H <= 125);
#satMask = (S >= 60) & (S <= 120);
#valMask = (V >= 70) & (V <= 120);
#HUE,SATURATION VE VALUE DEGERLERI ICIN MINUMUM VE MAKSIMUM ESIK DEGERLERI
#TANIMLANDI [14-16]
maske = uint8(hueMask );
maskAna = FG.*maske;
imwrite(maskAna,"C:/Users/ismail/Desktop/d/maskAna.jpg");
#BELIRLENEN ESIK DEGERLERINE GORE MASKE OLUSTURULDU VE ON YUZ FOTORAGRAFI
#ILE CARPILARAK MASKELENMIS ANA RESIM CIKTISI ELDE EDILDI[19-21]

maskAnaResimHSV = rgb2hsv(maskAna);
maskAna=uint8(255*maskAnaResimHSV(:,:,3));
#MASKELENMIS ANA RESMIMIZ TEKRARDAN HSV UZAYINA DONUSTURULDU 
#VE VALUE KATMANI ELE ALINDI [25-26]
imwrite(maskAna,"C:/Users/ismail/Desktop/d/maskAnaV.jpg");
#VALUE KATMANI ALINAN RESIM CIKTISI ALINDI
for i=1:sat
  for j=1:sut
    if maskAna(i,j)<=50
        mask2(i,j)=1;
        mask1(i,j)=0;
    else
      mask2(i,j)=0;
      mask1(i,j)=1;
    end
  end
end
imwrite(mask2,"C:/Users/ismail/Desktop/d/mask2.jpg");
imwrite(mask1,"C:/Users/ismail/Desktop/d/mask1.jpg");
#VALUE KATMANI ALINMIS RESIM FOR DONGUSUNE SOKULARAK VALUE DEGERI 50 YE ES?T 
#VEYA 50 N?N ALTINDA ?SE ?K? TANE B?RB?R?N?N TAM TERS? OLAN MASKELEME 
#GORUNTULERINI CIKTI OLARAK VERIR[31-43]
FGO(:,:,1)=mask2.*FG(:,:,1);
FGO(:,:,2)=mask2.*FG(:,:,2);
FGO(:,:,3)=mask2.*FG(:,:,3);
imwrite(FGO,"C:/Users/ismail/Desktop/d/FGO.jpg");
#ON YUZ FOTOGRAFI ILE ON YUZ MASKELEME MASKESINI CARPARAK ON YUZ ÇIKTI
#FOTOGRAFINI VERIR[47-50]
BGO(:,:,1)=mask1.*BG(:,:,1);
BGO(:,:,2)=mask1.*BG(:,:,2);
BGO(:,:,3)=mask1.*BG(:,:,3);
imwrite(BGO,"C:/Users/ismail/Desktop/d/BGO.jpg");
#ARKA YUZ FOTOGRAFI ILE ARKA YUZ MASKELEME MASKESINI CARPARAK ARKA YUZ ÇIKTI
#FOTOGRAFINI VERIR[53-56]
FGO = FGO +BGO;
imwrite(FGO,"C:/Users/ismail/Desktop/d/SON.jpg");
#ON YUZ VE ARKA YUZ FOTOGRAFI TOPLANARAK SON GORUNTU ELDE EDILIR
zu-fuss.m · 970 B · ext .m · SWH occurrences unknown
via swh_study:m (judge:claude-sonnet-4.6; judge:gemini-3.8-flash; human:mathieu-acher)
swh:1:cnt:bd36626611a8c98053f8c38bd231392b696158eb;origin=https://github.com/ColWalterEKurtz/Mathematik;path=/LineareGleichungen/zu-fuss.m
Open in SWH · Raw bytes (SWH)
Reviews (1 human, 2 LLM)
Ground truth · how?
👤 mathieu-acher → pl/octave (high) 2026-10-01
very basic piece of code for generating some LaTeX... certainly in Matlab | Revised after seeing the judges: uses printf(...), which MATLAB rejects — Octave-only syntax, so 'octave' under the study's definition. Original blind label was 'matlab' (reviewer applied MATLAB as the family label). Content: very basic script generating LaTeX exercise text.
🤖 anthropic-claude-sonnet-4.6 m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave script using printf()
🤖 google-gemini-3.8-flash m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave
Show source
clear all;

printf("\\begin{exercise}\n");
printf("      {ID-f90bda1b2e8304117908bebda30785ca79503dae}\n");
printf("      {Zu Fuß}\n");
printf("  \\ifproblem\\problem\n");
printf("    Onkel Josef möchte seine Nichte Josefine besuchen.\n");
printf("    Der Bahnhof, an dem er aussteigen muss, liegt noch \\sikm{36} von Josefines\n");
printf("    Heimatdorf entfernt. Nachdem er ausgestiegen ist, ruft er seine Nichte an und\n");
printf("    bittet sie ihn abzuholen. Diese setzt sich sofort in ihr Auto und fährt mit einer\n");
printf("    Durchschnittsgeschwindigkeit von \\sikmh{45} zum Bahnhof. Da Onkel Josef nicht\n");
printf("    warten will, geht er Josefine entgegen. Er schafft \\sikm{3} pro Stunde. Wie\n");
printf("    weit muss er gehen, bis er von seiner Nichte mitgenommen wird?\n");
printf("  \\fi\n");
printf("  %%\\ifoutline\\outline\n");
printf("  %%\\fi\n");
printf("  %%\\ifoutcome\\outcome\n");
printf("  %%\\fi\n");
printf("\\end{exercise}\n");

intersect.m · 3095 B · ext .m · SWH occurrences unknown
via swh_study:m (judge:claude-sonnet-4.6; judge:gemini-3.8-flash; human:mathieu-acher)
swh:1:cnt:bf8f93db910a97a6abf18a635043849fb0df9947;origin=https://github.com/oheim/octave-interval;path=/inst/@infsup/intersect.m
Open in SWH · Raw bytes (SWH)
Reviews (1 human, 2 LLM)
Ground truth · how?
👤 mathieu-acher → pl/octave (high) 2026-10-02
https://github.com/oheim/octave-interval
🤖 anthropic-claude-sonnet-4.6 m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave (octave-interval package, @infsup class method)
🤖 google-gemini-3.8-flash m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave
Show source
## Copyright 2014-2015 Oliver Heimlich
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @documentencoding utf-8
## @deftypefn {Function File} {} {} intersect (@var{A}, @var{B})
## 
## Intersect two intervals.
##
## Accuracy: The result is a tight enclosure.
##
## @example
## @group
## x = infsup (1, 3);
## y = infsup (2, 4);
## intersect (x, y)
##   @result{} [2, 3]
## @end group
## @end example
## @seealso{@@infsup/union, @@infsup/setdiff, @@infsup/setxor}
## @end deftypefn

## Author: Oliver Heimlich
## Keywords: interval
## Created: 2014-10-02

function result = intersect (a, b)

if (nargin ~= 2)
    print_usage ();
    return
endif
if (not (isa (a, "infsup")))
    a = infsup (a);
endif
if (not (isa (b, "infsup")))
    b = infsup (b);
endif

## This also works for unbound intervals and empty intervals
l = max (a.inf, b.inf);
u = min (a.sup, b.sup);

## If the intervals do not intersect, the result must be empty.
emptyresult = a.sup < b.inf | b.sup < a.inf;
l (emptyresult) = inf;
u (emptyresult) = -inf;

result = infsup (l, u);

endfunction

%!test "Empty interval";
%! assert (intersect (infsup (), infsup ()) == infsup ());
%! assert (intersect (infsup (), infsup (1)) == infsup ());
%! assert (intersect (infsup (0), infsup ()) == infsup ());
%! assert (intersect (infsup (-inf, inf), infsup ()) == infsup ());
%!test "Singleton intervals";
%! assert (intersect (infsup (0), infsup (1)) == infsup ());
%! assert (intersect (infsup (0), infsup (0)) == infsup (0));
%!test "Bounded intervals";
%! assert (intersect (infsup (1, 2), infsup (3, 4)) == infsup ());
%! assert (intersect (infsup (1, 2), infsup (2, 3)) == infsup (2));
%! assert (intersect (infsup (1, 2), infsup (1.5, 2.5)) == infsup (1.5, 2));
%! assert (intersect (infsup (1, 2), infsup (1, 2)) == infsup (1, 2));
%!test "Unbounded intervals";
%! assert (intersect (infsup (0, inf), infsup (-inf, 0)) == infsup (0));
%! assert (intersect (infsup (1, inf), infsup (-inf, -1)) == infsup ());
%! assert (intersect (infsup (-1, inf), infsup (-inf, 1)) == infsup (-1, 1));
%! assert (intersect (infsup (-inf, inf), infsup (42)) == infsup (42));
%! assert (intersect (infsup (42), infsup (-inf, inf)) == infsup (42));
%! assert (intersect (infsup (-inf, 0), infsup (-inf, inf)) == infsup (-inf, 0));
%! assert (intersect (infsup (-inf, inf), infsup (-inf, inf)) == infsup (-inf, inf));
%!test "from the documentation string";
%! assert (intersect (infsup (1, 3), infsup (2, 4)) == infsup (2, 3));
f.m · 2395 B · ext .m · SWH occurrences unknown
via swh_study:m (judge:claude-sonnet-4.6; judge:gemini-3.8-flash)
swh:1:cnt:84424ee591a72593533c3c575ce75067bff3a296;origin=https://github.com/lucasgamaleri/hl20_nlmodel_proj;path=/f.m
Open in SWH · Raw bytes (SWH)
Reviews (2 LLM)
Ground truth · how?
🤖 anthropic-claude-sonnet-4.6 m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave (endfunction, ## comments)
🤖 google-gemini-3.8-flash m-judge/1 → pl/octave (high) 2026-09-29
GNU Octave
Show source
function xp = f(t,y)
%y = [ uo vo wo 0 0 0 0 titacero ];
global rho 
global vinf
global sup
global b
global c
global g
global m
global de
global Ix
global Iy
global Iz
global V
global Po
V = sqrt(y(1)^2 + y(2)^2 + y(3)^2) ;
betha = asind(y(2)/vinf);
alpha = atand(y(3)/y(1));


fila1 = [1 alpha alpha^2 alpha^3 alpha^4 alpha^5 alpha^6 abs(betha) betha^2 abs(betha^3) betha^4 alpha*abs(betha)]; 

fila2 = [1 alpha alpha^2 alpha^3 alpha^4] ;

##Cxo =  fila1*hl20.Po(:,3)*-1 ;
##
##Czo = fila1*hl20.Po(:,1)*-1 ;
##
##Cmo = fila1*hl20.Po(:,2) ; 
##
##Czde= fila2*hl20.Pde(:,1)*-1 ;
##
##Cmde= fila2*hl20.Pde(:,2) ;
##
##Cxde= fila2*hl20.Pde(:,3)*-1 ;
##
##Cmq = interp1(hl20.Cdamp_alpha,hl20.Cmq,alpha);
##
##Cno = interp2(hl20.Cn_alpha,hl20.Cn_beta,hl20.Cn',alpha,abs(betha)); %(3,:) fila3 - ":" todas las columnas
##%Cno = interp1(hl20.Cn_beta,hl20.Cn(3,:),betha);
##
##Clp = interp1(hl20.Cdamp_alpha,hl20.Clp,alpha);
##
##Clr = interp1(hl20.Cdamp_alpha,hl20.Clr,alpha);
##
##Cnp = interp1(hl20.Cdamp_alpha,hl20.Cnp,alpha);
##
##Cnr = interp1(hl20.Cdamp_alpha,hl20.Cnr,alpha);

Cxo =  fila1*Po(:,3)*-1 ;

Czo = fila1*Po(:,1)*-1 ;

Cmo = fila1*Po(:,2) ; 

Czde= fila2*Pde(:,1)*-1 ;

Cmde= fila2*Pde(:,2) ;

Cxde= fila2*Pde(:,3)*-1 ;

Cmq = interp1(Cdamp_alpha,Cmq,alpha);

Cno = interp2(Cn_alpha,Cn_beta,Cn',alpha,abs(betha)); %(3,:) fila3 - ":" todas las columnas
%Cno = interp1(Cn_beta,Cn(3,:),betha);

Clp = interp1(Cdamp_alpha,Clp,alpha);

Clr = interp1(Cdamp_alpha,Clr,alpha);

Cnp = interp1(Cdamp_alpha,Cnp,alpha);

Cnr = interp1(Cdamp_alpha,Cnr,alpha);




xp(1)= ((0.5*rho*vinf^2*sup*(Cxo + Cxde*de) - m*g*sin(y(7)))/m) - y(5)*y(3) + y(6)*y(2);
xp(2)= ((0.5*rho*vinf^2*sup*(-0.01242*betha)+ m*g*cos(y(7))* sin(y(8)))/ m) - y(6)*y(1) + y(4)*y(3);
xp(3)= ((0.5*rho*vinf^2*sup*(Czo + Czde*de) + m*g*cos(y(7))*cos(y(8)))/m) - y(4)*y(2)+y(5)*y(1);
xp(4)= (0.5*rho*vinf^2*sup*b*(-0.00787*betha + Clp*((y(4)*b)/(2*V))+ Clr*((y(6)*b)/(2*V)))-y(5)*y(6)*(Iz-Iy))/Ix; 
xp(5)= (0.5*rho*vinf^2*sup*b*(Cmo + Cmq*((y(5)*c)/2*V) + Cmde*de )-y(5)*y(6)*(Ix-Iz))/Iy ;
xp(6)= (0.5*rho*vinf^2*sup*b*(Cno + Cnp*((y(4)*b)/(2*V)) + Cnr*((y(6)*b)/(2*V))) - y(4)*y(5)*(Iy-Ix))/Iz ;
xp(7)= y(5)*cos(y(8))- y(6)*sin(y(8));
xp(8)= y(4) + y(5)*sin(y(8))*tan(y(8)) + y(6)*cos(y(8))*tan(y(7)) ;

xp = xp';
    



endfunction


XSetModifierMapping.m · 13796 B · ext .m · SWH occurrences unknown
via manual-request
swh:1:cnt:f851a314d7b2dfc8949028f3671dba8f268ac4ee;origin=https://gitlab.freedesktop.org/xorg/test/xts;anchor=swh:1:rev:497a0865d1fa51adbba53c5c1c930dd18beacc4e;path=/xts5/tset/Xlib13/XSetModifierMapping/XSetModifierMapping.m
Open in SWH · Raw bytes (SWH)
Reviews (1 human)
Ground truth · how?
👤 mathieu-acher → pl/new:xlib-and-x-protocol-test-suite (medium) amended 2026-06-12
X Test Suite (XTS), test file for X11 https://www.freedesktop.org/software/fontconfig/xtest/progguide.pdf
Show source
Copyright (c) 2005 X.Org Foundation L.L.C.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
$Header: /cvs/xtest/xtest/xts5/tset/Xlib13/XSetModifierMapping/XSetModifierMapping.m,v 1.2 2005-11-03 08:42:41 jmichael Exp $

Copyright (c) Applied Testing and Technology, Inc. 1995
All Rights Reserved.

>># Project: VSW5
>># 
>># File: xts5/tset/Xlib13/XSetModifierMapping/XSetModifierMapping.m
>># 
>># Description:
>># 	Tests for XSetModifierMapping()
>># 
>># Modifications:
>># $Log: stmdfrmppn.m,v $
>># Revision 1.2  2005-11-03 08:42:41  jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.1.1.2  2005/04/15 14:05:19  anderson
>># Reimport of the base with the legal name in the copyright fixed.
>>#
>># Revision 8.0  1998/12/23 23:33:43  mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0  1998/10/30 22:55:28  mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0  1998/03/02 05:25:07  tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0  1998/01/26 03:21:39  tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.0  1995/12/15 09:08:39  tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1  1995/12/15  01:10:04  andy
>># Prepare for GA Release
>>#
/*
Portions of this software are based on Xlib and X Protocol Test Suite.
We have used this material under the terms of its copyright, which grants
free use, subject to the conditions below.  Note however that those
portions of this software that are based on the original Test Suite have
been significantly revised and that all such revisions are copyright (c)
1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
revisions cannot be separated from the freely copyable material, the net
result is that use of this software is governed by the ApTest copyright.

Copyright (c) 1990, 1991  X Consortium

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.

Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of UniSoft not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  UniSoft
makes no representations about the suitability of this software for any
purpose.  It is provided "as is" without express or implied warranty.
*/
>>TITLE XSetModifierMapping Xlib13
int
xname
Display	*display = Dsp;
XModifierKeymap	*modmap;
>>SET return-value MappingSuccess
>>EXTERN

static	XModifierKeymap	*origmap;

static	int	Minkc, Maxkc;

>>SET startup savemap
static void
savemap()
{
	startup();
	if(Dsp) {
		origmap = XGetModifierMapping(Dsp);
		XDisplayKeycodes(Dsp, &Minkc, &Maxkc);
	}
}

>>SET cleanup cleanmap
static void
cleanmap()
{
	if(Dsp)
		XSetModifierMapping(Dsp, origmap);
	cleanup();
}

>>ASSERTION Good A
A succesful call to xname
specifies the KeyCodes of the keys that are to be used
as modifiers and returns
.S MappingSuccess .
>>STRATEGY
Set up a modifier map.
Call xname to set servers map.
Verify that MappingSuccess is returned.
Get current map with XGetModifierMapping.
Verify that the mapping has been set correctly.
>>CODE
int 	i;
int 	kpm;
XModifierKeymap	*newmap;

	/*
	 * Because some keycodes may not be usable as modifiers in a server
	 * dependent fashion, then we must take steps to avoid this.
	 * Therefore: get current modifiers and rearrange them.
	 */
	kpm = origmap->max_keypermod;
	modmap = XNewModifiermap(kpm);
	if (modmap == 0) {
		delete("Could not create new map");
		return;
	}

	for (i = 0; i < kpm*8; i++)
		modmap->modifiermap[i] = origmap->modifiermap[kpm*8-1 - i];

	XCALL;

	newmap = XGetModifierMapping(display);

	if (newmap->max_keypermod == modmap->max_keypermod)
		CHECK;
	else {
		report("max_keypermod was %d, expecting %d", newmap->max_keypermod,
			modmap->max_keypermod);
		FAIL;
	}
	for (i = 0; i < kpm*8; i++) {
		if (modmap->modifiermap[i] == newmap->modifiermap[i])
			CHECK;
		else {
			report("Modifier map was not set correctly");
			FAIL;
			break;
		}
	}
	CHECKPASS(1+kpm*8);

	XFreeModifiermap(newmap);
>>ASSERTION Good A
When a call to xname succeeds, then a
.S MappingNotify
event is generated.
>>STRATEGY
Call xname to set mapping.
Verify that a MappingNotify event is generated.
>>CODE
int 	n;
XEvent	ev;
XMappingEvent	good;

	modmap = origmap;

	XCALL;

	defsetevent(good, display, MappingNotify);
	good.window = None;	/* unused */
	good.request = MappingModifier;
	/* rest not used */

	n = getevent(display, &ev);
	if (n == 0 || ev.type != MappingNotify) {
		report("Expecting a MappingNotify event");
		FAIL;
		return;
	} else
		CHECK;

	if (checkevent((XEvent*)&good, &ev))
		FAIL;
	else
		CHECK;

	CHECKPASS(2);
>>ASSERTION def
The
.M modifiermap
member of the
.S XModifierKeymap
structure contains eight sets of
.M max_keypermod
KeyCodes, one for each modifier in the order
.S Shift ,
.S Lock ,
.S Control ,
.S Mod1 ,
.S Mod2 ,
.S Mod3 ,
.S Mod4 ,
and
.S Mod5 .
>>ASSERTION Good A
When a zero KeyCode occurs in a set, then it is ignored.
>>STRATEGY
>># This is not really true in any sense that we can test.
>># Check that 0 does not generate BadValue when used multiple times.
Set up a mapping with all keycodes zero.
Set mapping with xname.
Verify no BadValue error.
>># Verify that mapping did not change.
>>CODE
XModifierKeymap	*oldmap;
int 	i;

	oldmap = XGetModifierMapping(display);
	if (oldmap == 0) {
		delete("Could not get the old map");
		return;
	}

	modmap = XNewModifiermap(1);
	for (i = 0; i < 8; i++)
		modmap->modifiermap[i] = 0;

	XCALL;

	if (geterr() == Success)
		CHECK;

	CHECKPASS(1);

>>ASSERTION Bad C
When an implementation restriction on which keys can be used
as modifiers is violated,
then a call to xname returns
.S MappingFailed
and none of the modifiers are changed.
>>STRATEGY
Try in turn all possible keycodes.
If all return MappingSuccess:
  Report unsupported.
else
  Verify that MappingFailed is returned.
  Verify that modifier has not been set to this keycode.
>>CODE
int 	i;
int 	ret;
int 	found;
XModifierKeymap *newmap;
unsigned int	kc;

	if ((modmap = XNewModifiermap(1)) == 0) {
		delete("Failed to create new modifier map");
		return;
	}

	for (i = 0; i < 8; i++)
		modmap->modifiermap[i] = 0;

	found = 0;
	for (kc = Minkc; kc <= Maxkc; kc++) {
		modmap->modifiermap[0] = (KeyCode)kc;

		ret = XCALL;

		if (ret != MappingSuccess) {

			found = True;

			if (ret != MappingFailed) {
				report("Return value was %d, expecting MappingFailure", ret);
				FAIL;
				break;
			}
			newmap = XGetModifierMapping(display);

			if (newmap->modifiermap[0] == (KeyCode)kc) {
				report("An invalid keycode (%u) was set into the map", kc);
				FAIL;
				break;
			} else
				CHECK;
		} else
			CHECK;
	}

	if (!found)
		unsupported("All keycodes are acceptable as modifiers for this server");
	else
		CHECKPASS(Maxkc-Minkc+1);

>>ASSERTION Bad B 3
When the new KeyCodes specified for a modifier differ from those
currently defined and any of the
current or new keys for that modifier are
in the logically down state, then a call to xname returns
.S MappingBusy
and none of the modifiers are changed.
>>STRATEGY
If extension available:
  Get current modifier mapping (other tests may have changed it from origmap).
  Make a new modifier map by permuting the old.
  Check there is at least one non-zero keycode in it.
  Simulate pressing this key using extension.
  Call xname to set the new mod. map.
  Expect MappingBusy
  Release all keys.
  Get current mapping with XGetModifierMapping.
  Compare with that got at first.
  Remove key from map.
  Simulate pressing key not in the map.
  Call xname.
  Expect MappingBusy as one of current (at time of xname call) mod keys pressed.
  Release all keys.
  Call xname to set up map to not include this key.
  Expect MappingSuccess.
  Simulate pressing key not in the map.
  Call xname.
  Expect !MappingBusy as key not in current or new maps (at time of xname call).
  Release all keys.
else
  Report untested.
>>CODE
int 	i;
int 	kpm;
int	modkc;
XModifierKeymap	*newmap;
XModifierKeymap	*oldmap;
int	ret;
KeyCode *kcp;

	if (noext(0))
		return;
	else
		CHECK;

	oldmap = XGetModifierMapping(display);

	/*
	 * Because some keycodes may not be usable as modifiers in a server
	 * dependent fashion, then we must take steps to avoid this.
	 * Therefore: get current modifiers and rearrange them.
	 */
	kpm = oldmap->max_keypermod;
	modmap = XNewModifiermap(kpm);
	if (modmap == 0) {
		delete("Could not create new map");
		XFreeModifiermap(oldmap);
		return;
	}

	modkc = 0;
	for (i = 0; i < kpm*8; i++) {
		KeyCode kc = modmap->modifiermap[i] = oldmap->modifiermap[kpm*8-1 - i];

		if (!modkc && kc) {
			modkc = kc;
			kcp = &(modmap->modifiermap[i]);
		}
	}

	if (!modkc) {
		delete("Can't find a usable modifier key code.");
		XFreeModifiermap(oldmap);
		XFreeModifiermap(modmap);
		return;
	} else
		CHECK;

	keypress(display, modkc);

	ret = XCALL;

	relalldev();

	if (ret == MappingBusy)
		CHECK;
	else {
		report("Key %d did not cause MappingBusy when pressed.", modkc);
		FAIL;
	}
	/* now check no change occurred */
	newmap = XGetModifierMapping(display);

	if (newmap->max_keypermod == oldmap->max_keypermod)
		CHECK;
	else {
		report("max_keypermod was %d, expecting %d", newmap->max_keypermod,
			oldmap->max_keypermod);
		FAIL;
	}
	for (i = 0; i < kpm*8; i++) {
		if (oldmap->modifiermap[i] == newmap->modifiermap[i])
			CHECK;
		else {
			report("Modifier map was not set correctly");
			FAIL;
			break;
		}
	}

	/* use a key not in new map, but in current, and expect MappingBusy */
	*kcp = 0; /* remove modkc from map */
	keypress(display, modkc);
	ret = XCALL;
	relalldev();

	if (ret == MappingBusy)
		CHECK;
	else {
		report("Pressing key %d caused %s, not MappingBusy, though in old map.",
			modkc, (ret==MappingSuccess)?"MappingSuccess":"MappingFailed");
		FAIL;
	}
	/* make sure that key is not in map, now */
	ret = XCALL;
	if (ret != MappingSuccess) {
		delete("Can't install new mod. map not including key %d.", modkc);
		XFreeModifiermap(modmap);
		XFreeModifiermap(oldmap);
		XFreeModifiermap(newmap);
		return;
	} else
		CHECK;
	/* use a key not in the new or current map and expect other than MappingBusy */
	keypress(display, modkc);
	ret = XCALL;
	relalldev();

	if (ret != MappingBusy)
		CHECK;
	else {
		report("Pressing key %d caused MappingBusy though not in new or old map.", modkc);
		FAIL;
	}

	XFreeModifiermap(modmap);
	XFreeModifiermap(oldmap);
	XFreeModifiermap(newmap);

	CHECKPASS(7 + kpm*8);
>>SET return-value MappingSuccess
>>ASSERTION Bad B 3
.ER BadAlloc
>>ASSERTION Bad A
When a KeyCode is not in the range returned by
>># This was an error not spotted in the assertion reviews.
>># .F XDisplayCodes ,
.F XDisplayKeycodes ,
then a
.S BadValue
error occurs.
>>STRATEGY
Call XDisplayKeycodes to get range of valid keycodes.
Set up map with keycode less than the minimum value.
Call xname.
Verify that a BadValue error occurs.

Set up map with keycode greater than the maximum value (if possible).
Call xname.
Verify that a BadValue error occurs.
>>CODE BadValue
>>SET return-value MappingFailed
int 	i;

	modmap = XNewModifiermap(1);
	for (i = 0; i < 8*modmap->max_keypermod; i++)
		modmap->modifiermap[i] = 0;

	modmap->modifiermap[0] = Minkc-1;
	XCALL;

	if (geterr() == BadValue)
		CHECK;
	else
		FAIL;

	if (Maxkc+1 < 0xff) {
		modmap->modifiermap[0] = Maxkc+1;
		XCALL;

		if (geterr() == BadValue)
			CHECK;
		else
			FAIL;
	} else
		CHECK;

	CHECKPASS(2);

Programs collected by LLM agents experimental · unverified

Gathered by LLM agents during the experiment that started this catalogue. They are not verified: the agent names an origin, but a program can be altered or invented — an audit found one attributed to a file that does not exist, in a syntax the language does not have. Prefer the programs archived by Software Heritage above. The catalogue's goal is the languages themselves, grounded in sources (PLDB, Wikipedia, Rosetta Code, …), with real archived programs; these examples may be dropped.

Fibonacci Sequence Generator and Plotter

Provenance: commit be17780cfb · authored 2026-02-06T09:35:14+01:00 · agent claude-code · model sonnet · WebSearch disabled
code.m · added: 2026-02-06T12:00:00Z
% Fibonacci sequence generator
function fib = fibonacci(n)
    if n <= 0
        fib = [];
    elseif n == 1
        fib = 1;
    elseif n == 2
        fib = [1, 1];
    else
        fib = zeros(1, n);
        fib(1) = 1;
        fib(2) = 1;
        for i = 3:n
            fib(i) = fib(i-1) + fib(i-2);
        end
    end
end

% Generate first 15 Fibonacci numbers
n = 15;
fib_sequence = fibonacci(n);

% Display the sequence
disp('Fibonacci sequence:');
disp(fib_sequence);

% Plot the sequence
plot(1:n, fib_sequence, '-o', 'LineWidth', 2);
xlabel('Position');
ylabel('Fibonacci Number');
title('Fibonacci Sequence');
grid on;

Contribute — propose a file extension

Tell us where to find evidence about Octave (mapped to pl/octave). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Octave/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← OCPL Octive →