This file is indexed.

/usr/share/yacas/plots.rep/backends-3d.ys is in yacas 1.3.3-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//////////////////////////////////////////////////
/// Backends for 3D plotting
//////////////////////////////////////////////////

/// List of all defined backends and their symbolic labels.
/// Add any new backends here 
Plot3DS'outputs() := {
	{"default", "gnuplot"},
	{"data", "Plot3DS'data"},
	{"gnuplot", "Plot3DS'gnuplot"},
};

/*
	How backends work:
	Plot3DS'<backend>(values, options'hash)
	options'hash is a hash that contains all plotting options:
	["xrange"] - a list of {x1, x2}, ["xname"] - name of the variable to plot, same for "yrange";
	["zname"] - array of string representations of the function(s), and perhaps other options relevant to the particular backend.
	{values} is a list of lists of triples of the form {{{x1, y1, z1}, {x2, y2, z2}, ...}, {{x1, y1, t1}, {x2, y2, t2}, ...}, ...} corresponding to the functions z(x,y), t(x,y), ... to be plotted. The points x[i], y[i] are not necessarily the same for all functions.
	The backend should prepare the graph of the function(s). The "datafile" backend Plot3DS'datafile(values, options'hash) may be used to output all data to file(s), in which case the file name should be given by the value options'hash["filename"]. Multiple files are created with names obtained by appending numbers to the filename.
	Note that the "data" backend does not do anything and simply returns the data.
	The backend Plot3DS'datafile takes care not to write "Infinity" or "Undefined" data points (it just ignores them). Custom backends should either use Plot3DS'datafile to prepare a file, or take care of this themselves.
*/

/// trivial backend: return data list (do not confuse with Plot3DS'get'data() defined in the main code which is the middle-level plotting routine)
Plot3DS'data(values_IsList, _options'hash) <-- values;

/// backend: display graph using gnuplot
Plot3DS'gnuplot(values_IsList, _options'hash) <--
[
  Local(item, dirBase, filename'list, control'file);
  filename'list := Plot3DS'datafile(values, options'hash);
  control'file := TmpFile();
  ToFile(control'file)
  [
        WriteString("set surface" : Nl() : If(options'hash["hidden"], "set hidden3d" : Nl(), ""));
        // 'set xrange [-5:5]'
        WriteString("set xrange [");
        Write(options'hash["xrange"][1]);
        WriteString(" : ");
        Write(options'hash["xrange"][2]);
        WriteString("]" : Nl());
        WriteString("set yrange [");
        Write(options'hash["yrange"][1]);
        WriteString(" : ");
        Write(options'hash["yrange"][2]);
        WriteString("]" : Nl());
        If(
                options'hash["zrange"] != Empty,
                [
                        WriteString("set zrange [");
                        Write(options'hash["zrange"][1]);
                        WriteString(" : ");
                        Write(options'hash["zrange"][2]);
                        WriteString("]" : Nl());
                ]
        );
        WriteString("set dgrid3d ");
        Write(1+options'hash["xpoints"]*2^(options'hash["depth"] - options'hash["used depth"]));
        WriteString(",");
        Write(1+options'hash["ypoints"]*2^(options'hash["depth"] - options'hash["used depth"]));
        WriteString(",");
        Write(4);       // gnuplot's "norm" for its primitive interpolation
        WriteString(Nl());
        // 'plot "data1" title "y(x)" with lines, "data2" title "z(x)" with lines'
        WriteString("splot ");
        For(item:=1, item<=Length(values), item++)
        [
                WriteString("\"" : filename'list[item] : "\" title \"" : options'hash["zname"][item] : "\" with lines");
                If(item<Length(values), WriteString(", "));
        ];
        WriteString(Nl());
  ];
  SystemCall("gnuplot --persist " : control'file : " < /dev/null > /dev/null");
];

/// backend: write data into file.
/// Returns the list of created filenames
/// This backend is used by other backends to write data to files.
Plot3DS'datafile(values_IsList, _options'hash) <--
[
        Local(item, func, filename, filename'list);
        filename'list := {};
        For(func:=1, func<=Length(values), func++)
        [
                filename := TmpFile();
                DestructiveAppend(filename'list, filename);
                ToFile(filename) ForEach(item, values[func]) WriteDataItem(item, options'hash);
                If(InVerboseMode(), Echo( "Plot3DS'datafile: created file '" : filename :  "'"), True);
        ];
        filename'list;
];