This file is indexed.

/usr/share/doc/libplplot12/examples/tcl/x22.tcl is in plplot-tcl-dev 5.10.0+dfsg2-0.1ubuntu2.

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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#----------------------------------------------------------------------------
# $Id: x22.tcl 12806 2013-12-03 13:03:26Z andrewross $
#----------------------------------------------------------------------------

# Vector plot demo.

proc x22 {{w loopback}} {
    matrix arrow_x f 6 = {-0.5, 0.5, 0.3, 0.5, 0.3, 0.5}
    matrix arrow_y f 6 = {0.0, 0.0, 0.2, 0.0, -0.2, 0.0}
    matrix arrow2_x f 6 = {-0.5, 0.3, 0.3, 0.5, 0.3, 0.3}
    matrix arrow2_y f 6 = {0.0, 0.0,   0.2, 0.0, -0.2, 0.0}

    circulation $w

    set narr 6
    set fill 0

    $w cmd plsvect arrow_x arrow_y $fill
    constriction $w 1

    set fill 1
    $w cmd plsvect arrow2_x  arrow2_y $fill
    constriction $w 2

    constriction2 $w

    $w cmd plsvect NULL NULL 0

    potential $w
}

# Vector plot of circulation about the origin
proc circulation {w} {
    set nx 20
    set ny 20

    set dx 1.0
    set dy 1.0

    set xmin [expr {-$nx/2*$dx}]
    set xmax [expr {$nx/2*$dx}]
    set ymin [expr {-$ny/2*$dy}]
    set ymax [expr {$ny/2*$dy}]

    matrix xg f $nx $ny
    matrix yg f $nx $ny
    matrix u f $nx $ny
    matrix v f $nx $ny

    # Create data - circulation around the origin.
    for {set i 0} {$i < $nx} {incr i} {
	set x [expr {($i-$nx/2+0.5)*$dx} ]
	for {set j 0} {$j < $ny} {incr j} {
	    set y [expr {($j-$ny/2+0.5)*$dy}]
	    xg $i $j = $x
	    yg $i $j = $y
	    u $i $j = $y
	    v $i $j = [expr {-1.0*$x}]
	}
    }

    # Plot vectors with default arrows
    $w cmd plenv $xmin $xmax $ymin $ymax 0 0
    $w cmd pllab "(x)" "(y)" "#frPLplot Example 22 - circulation"
    $w cmd plcol0 2
    $w cmd plvect u v 0.0 "pltr2" xg yg
    $w cmd plcol0 1

}

# Vector plot of flow through a constricted pipe
proc constriction {w astyle} {

    set nx 20
    set ny 20

    set dx 1.0
    set dy 1.0

    set xmin [expr {-$nx/2*$dx}]
    set xmax [expr {$nx/2*$dx}]
    set ymin [expr {-$ny/2*$dy}]
    set ymax [expr {$ny/2*$dy}]

    matrix xg f $nx $ny
    matrix yg f $nx $ny
    matrix u f $nx $ny
    matrix v f $nx $ny

    set Q 2.0
    # Create data - circulation around the origin.
    for {set i 0} {$i < $nx} {incr i} {
	set x [expr {($i-$nx/2+0.5)*$dx} ]
	for {set j 0} {$j < $ny} {incr j} {
	    set y [expr {($j-$ny/2+0.5)*$dy}]
	    xg $i $j = $x
	    yg $i $j = $y
	    set b [expr {$ymax/4.0*(3.0-cos($::PLPLOT::PL_PI*$x/$xmax))}]
	    if {abs($y) < $b} {
		set dbdx [expr {$ymax/4.0*sin($::PLPLOT::PL_PI*$x/$xmax)*$::PLPLOT::PL_PI/$xmax*$y/$b}]
		u $i $j = [expr {$Q*$ymax/$b}]
		v $i $j = [expr {$Q*$ymax/$b*$dbdx}]
	    } else {
		u $i $j = 0.0
		v $i $j = 0.0
	    }
	}
    }

    # Plot vectors with default arrows
    $w cmd plenv $xmin $xmax $ymin $ymax 0 0
    $w cmd pllab "(x)" "(y)" [format "#frPLplot Example 22 - constriction (arrow style %d)" $astyle]
    $w cmd plcol0 2
    $w cmd plvect u v -1.0 "pltr2" xg yg
    $w cmd plcol0 1

}

proc transform { x y } {

    global xmax

    return [list \
                [expr {$x}] \
                [expr {$y / 4.0 * (3.0 - cos($::PLPLOT::PL_PI * $x / $xmax) ) }]]
}

# Vector plot of flow through a constricted pipe
# with a coordinate transform
proc constriction2 {w} {

    set nx 20
    set ny 20
    set nc 11
    set nseg 20

    set dx 1.0
    set dy 1.0

    global xmax

    set xmin [expr {-$nx/2*$dx}]
    set xmax [expr {$nx/2*$dx}]
    set ymin [expr {-$ny/2*$dy}]
    set ymax [expr {$ny/2*$dy}]

    $w cmd plstransform transform

    matrix xg f $nx $ny
    matrix yg f $nx $ny
    matrix u f $nx $ny
    matrix v f $nx $ny

    set Q 2.0
    # Create data - circulation around the origin.
    for {set i 0} {$i < $nx} {incr i} {
        set x [expr {($i-$nx/2+0.5)*$dx} ]
        for {set j 0} {$j < $ny} {incr j} {
            set y [expr {($j-$ny/2+0.5)*$dy}]
            xg $i $j = $x
            yg $i $j = $y
            set b [expr {$ymax/4.0*(3.0-cos($::PLPLOT::PL_PI*$x/$xmax))}]
            u $i $j = [expr {$Q*$ymax/$b}]
            v $i $j = 0.0
        }
    }

    matrix clev f $nc
    for {set i 0} {$i < $nc} {incr i} {
        clev $i = [expr {$Q + $i * $Q / ($nc - 1)}]
    }

    # Plot vectors with default arrows
    $w cmd plenv $xmin $xmax $ymin $ymax 0 0
    $w cmd pllab "(x)" "(y)" "#frPLplot Example 22 - constriction with plstransform"
    $w cmd plcol0 2
    $w cmd plshades u [expr {$xmin + $dx/2}] [expr {$xmax - $dx/2}] \
        [expr {$ymin + $dy/2}]  [expr {$ymax - $dy/2}] \
        clev 0.0 1 1.0 0 NULL
    $w cmd plvect u v -1.0 "pltr2" xg yg
    $w cmd plpath $nseg $xmin $ymax $xmax $ymax
    $w cmd plpath $nseg $xmin $ymin $xmax $ymin
    $w cmd plcol0 1

    $w cmd plstransform NULL

}



# Vector plot of the gradient of a shielded potential (see example 9)
proc potential {w} {

    set nr 20
    set ntheta 20
    set nper 100
    set nlevel 10

    matrix xg f $nr $ntheta
    matrix yg f $nr $ntheta
    matrix u f $nr $ntheta
    matrix v f $nr $ntheta
    matrix z f $nr $ntheta

    # Potential inside a conducting cylinder (or sphere) by method of images.
    # Charge 1 is placed at (d1, d1), with image charge at (d2, d2).
    # Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).
    # Also put in smoothing term at small distances.

    set rmax $nr

    set eps 2.

    set q1 1.
    set d1 [expr {$rmax/4.}]

    set q1i [expr {- $q1*$rmax/$d1}]
    set d1i [expr {pow($rmax,2)/$d1}]

    set q2 -1.
    set d2 [expr {$rmax/4.}]

    set q2i [expr {- $q2*$rmax/$d2}]
    set d2i [expr {pow($rmax,2)/$d2}]

    for {set i 0} {$i < $nr} {incr i} {
        set r [expr {0.5 + $i}]
        for {set j 0} {$j < $ntheta} {incr j} {
            set theta [expr {(2. * $::PLPLOT::PL_PI  / ($ntheta - 1.))*(0.5 + $j)}]
	    set x [expr {$r * cos($theta)}]
	    set y [expr {$r * sin($theta)}]
            xg $i $j = $x
            yg $i $j = $y
	    set div1 [expr {sqrt(pow($x-$d1,2) + pow($y-$d1,2) +
				 pow($eps,2))}]
	    set div1i [expr {sqrt(pow($x-$d1i,2) + pow($y-$d1i,2) + pow($eps,2))}]
	    set div2 [expr {sqrt(pow($x-$d2,2) + pow($y+$d2,2) +
				 pow($eps,2))}]
	    set div2i [expr {sqrt(pow($x-$d2i,2) + pow($y+$d2i,2) + pow($eps,2))}]
	    z $i $j = [expr {$q1/$div1 + $q1i/$div1i + $q2/$div2 + $q2i/$div2i}]
	    u $i $j = [expr {-$q1*($x-$d1)/pow($div1,3) - $q1i*($x-$d1i)/pow($div1i,3) -
			     $q2*($x-$d2)/pow($div2,3) - $q2i*($x-$d2i)/pow($div2i,3)}]
	    v $i $j = [expr {-$q1*($y-$d1)/pow($div1,3) - $q1i*($y-$d1i)/pow($div1i,3) -
			     $q2*($y+$d2)/pow($div2,3) - $q2i*($y+$d2i)/pow($div2i,3)}]
        }
    }

    set xmin [xg 0 0]
    set xmax $xmin
    set ymin [yg 0 0]
    set ymax $ymin
    set zmin [z 0 0]
    set zmax $zmin
    for {set i 0} {$i < $nr} {incr i} {
       for {set j 0} {$j < $ntheta} {incr j} {
          if {[xg $i $j] < $xmin} { set xmin [xg $i $j] }
          if {[xg $i $j] > $xmax} { set xmax [xg $i $j] }
          if {[yg $i $j] < $ymin} { set ymin [yg $i $j] }
          if {[yg $i $j] > $ymax} { set ymax [yg $i $j] }
          if {[z $i $j] < $zmin} { set zmin [z $i $j] }
          if {[z $i $j] > $zmax} { set zmax [z $i $j] }
       }
    }


    $w cmd plenv $xmin $xmax $ymin $ymax 0 0
    $w cmd pllab "(x)" "(y)" "#frPLplot Example 22 - potential gradient vector plot"
    # Plot contours of the potential
    set dz [expr {($zmax-$zmin)/$nlevel}]
    matrix clevel f $nlevel
    for {set i 0} {$i < $nlevel} {incr i} {
       clevel $i = [expr {$zmin + ($i + 0.5)*$dz}]
     }
    $w cmd plcol0 3
    $w cmd pllsty 2
    $w cmd plcont z clevel "pltr2" xg yg
    $w cmd pllsty 1
    $w cmd plcol0 1

    # Plot vectors with default arrows
    $w cmd plcol0 2
    $w cmd plvect u v 25.0 "pltr2" xg yg
    $w cmd plcol0 1

    # Plot the perimeter of the cylinder
    matrix px f $nper
    matrix py f $nper
    set dtheta [expr {2.0*$::PLPLOT::PL_PI/($nper-1.0)}]
    for {set i 0} {$i < $nper} {incr i} {
	set theta [expr {$dtheta*$i}]
	px $i = [expr {$rmax*cos($theta)}]
	py $i = [expr {$rmax*sin($theta)}]
    }
    $w cmd plline $nper px py

}