This file is indexed.

/usr/include/plplot/tclMatrix.h is in plplot-tcl-dev 5.10.0+dfsg-1.

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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
// -*-C++-*-
// $Id: tclMatrix.h 12078 2011-11-30 22:09:07Z andrewross $
//
//  Copyright 1994, 1995
//  Maurice LeBrun			mjl@dino.ph.utexas.edu
//  Institute for Fusion Studies	University of Texas at Austin
//
//  Copyright (C) 2004  Maurice LeBrun
//
//  This file is part of PLplot.
//
//  PLplot 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 2 of the License, or
//  (at your option) any later version.
//
//  PLplot 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 PLplot; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
//--------------------------------------------------------------------------
//
//  Contains declarations for Tcl "Matrix" command.
//  C functions that need access to the matrix data will need
//  to include this file.
//

#ifndef __TCLMATRIX_H__
#define __TCLMATRIX_H__

#include "plplot.h"
#include <tcl.h>

typedef PLFLT   Mat_float;

#if defined ( MSDOS )
typedef long    Mat_int;
#else
typedef int     Mat_int;
#endif

enum { TYPE_FLOAT, TYPE_INT };

// Arrays are column dominant (normal C ordering)
// Array elements are stored contiguously
// Require dimension <= 3 for simplicity

#define MAX_ARRAY_DIM    3

// Useful macros for index calculations

#define I3D( i, j, k )    k + matPtr->n[2] * ( I2D( i, j ) )
#define I2D( i, j )       j + matPtr->n[1] * ( I1D( i ) )
#define I1D( i )          i

// Matrix operator data

typedef struct
{
    int        type;             // Data type
    int        len;              // Total length of array
    int        dim;              // Number of dimensions
    int        n[MAX_ARRAY_DIM]; // Holds array length in each dimension
    int        tracing;          // Set if not persistent

    char       *name;            // Matrix operator name, malloc'ed

    Mat_float  *fdata;           // Floating point data, malloc'ed
    Mat_int    *idata;           // Integer data, malloc'ed

    Tcl_Interp *interp;          // Interpreter where command is installed

// These do the put/get operations for each supported type

    void ( *put )( ClientData clientData, Tcl_Interp* interp, int index, const char *string );
    void ( *get )( ClientData clientData, Tcl_Interp* interp, int index, char *string );
} tclMatrix;

// Function prototypes

#ifdef __cplusplus
//--------------------------------------------------------------------------
// // Since C++ does not generally have a per-platform ABI the way C
// // does, we stick to a totally inline class declaration and
// // definition.  That way you don't have to keep a separate version of
// // libplplot*.a for each compiler you'd like to use.
//
// // Start by setting up some important macros.
//

#include <iostream>

#ifdef throw
#define TCL_NO_UNDEF
#endif

#ifndef throw
#ifdef __hpux
#if defined ( __GNUC__ ) || defined ( __lucid ) || defined ( __CENTERLINE__ ) \
    || defined ( CENTERLINE_CLPP )
#define NO_XCPT
#endif
#else
#define NO_XCPT
#endif

#ifdef NO_XCPT
#define try
#define throw( a )                                     \
    { cerr << "THROW: " << # a << " from " << __FILE__ \
           << " line " << __LINE__ << endl << flush; abort(); }
#define catch( a )    if ( 0 )
#define Throw
#else
#define Throw    throw
#endif
#endif

#define tMat_Assert( a, b )    if ( !( a ) )                   \
    { using namespace std;                                     \
      cerr << "Assertion " << # a << " failed in " << __FILE__ \
           << " at line " << __LINE__ << endl << flush;        \
      throw( b ); }

//--------------------------------------------------------------------------
// // class TclMatFloat
//
// // This class provides a convenient way to access the data of a
// // tclMatrix from within compiled code.  Someone should make clones of
// // this class for the other tclMatrix supported data types.
//--------------------------------------------------------------------------

class TclMatFloat {
    tclMatrix *matPtr;
public:
    TclMatFloat( tclMatrix * ptm )
        : matPtr( ptm )
    {
        tMat_Assert( matPtr->type == TYPE_FLOAT, "Type mismatch" );
    }

    int Dimensions() const
    {
        return matPtr->dim;
    }

    int dim_size( int d ) const
    {
        tMat_Assert( d < matPtr->dim, "Range error." );
        return matPtr->n[d];
    }

    void redim( int nx )
    {
        free( matPtr->fdata );
        matPtr->dim   = 1;
        matPtr->n[0]  = nx;
        matPtr->len   = nx;
        matPtr->fdata = (Mat_float *) malloc( matPtr->len *
            sizeof ( Mat_float ) );
    }

    void redim( int nx, int ny )
    {
        free( matPtr->fdata );
        matPtr->dim   = 2;
        matPtr->n[0]  = nx;
        matPtr->n[1]  = ny;
        matPtr->len   = nx * ny;
        matPtr->fdata = (Mat_float *) malloc( matPtr->len *
            sizeof ( Mat_float ) );
    }

    void redim( int nx, int ny, int nz )
    {
        free( matPtr->fdata );
        matPtr->dim   = 3;
        matPtr->n[0]  = nx;
        matPtr->n[1]  = ny;
        matPtr->n[2]  = nz;
        matPtr->len   = nx * ny * nz;
        matPtr->fdata = (Mat_float *) malloc( matPtr->len *
            sizeof ( Mat_float ) );
    }

    Mat_float& operator() ( int i )
    {
        tMat_Assert( matPtr->dim == 1, "Wrong number of indicies." );
        tMat_Assert( i >= 0 && i < matPtr->n[0],
            "Out of bounds reference" );

        return matPtr->fdata[i];
    }

    Mat_float& operator() ( int i, int j )
    {
        tMat_Assert( matPtr->dim == 2, "Wrong number of indicies." );
        tMat_Assert( i >= 0 && i < matPtr->n[0] &&
            j >= 0 && j < matPtr->n[1],
            "Out of bounds reference" );

        return matPtr->fdata[I2D( i, j )];
    }

    Mat_float& operator() ( int i, int j, int k )
    {
        tMat_Assert( matPtr->dim == 3, "Wrong number of indicies." );
        tMat_Assert( i >= 0 && i < matPtr->n[0] &&
            j >= 0 && j < matPtr->n[1] &&
            k >= 0 && k < matPtr->n[2],
            "Out of bounds reference" );

        return matPtr->fdata[I3D( i, j, k )];
    }
};

//--------------------------------------------------------------------------
// // class TclMatInt
//
// // This class provides a convenient way to access the data of a
// // tclMatrix from within compiled code.  This is just like TclMatFloat above,
// // but for ints.
//--------------------------------------------------------------------------

class TclMatInt {
    tclMatrix *matPtr;
public:
    TclMatInt( tclMatrix * ptm )
        : matPtr( ptm )
    {
        tMat_Assert( matPtr->type == TYPE_INT, "Type mismatch" );
    }

    int Dimensions() const
    {
        return matPtr->dim;
    }

    int dim_size( int d ) const
    {
        tMat_Assert( d < matPtr->dim, "Range error." );
        return matPtr->n[d];
    }

    void redim( int nx )
    {
        free( matPtr->idata );
        matPtr->dim   = 1;
        matPtr->n[0]  = nx;
        matPtr->len   = nx;
        matPtr->idata = (Mat_int *) malloc( matPtr->len * sizeof ( Mat_int ) );
    }

    void redim( int nx, int ny )
    {
        free( matPtr->idata );
        matPtr->dim   = 2;
        matPtr->n[0]  = nx;
        matPtr->n[1]  = ny;
        matPtr->len   = nx * ny;
        matPtr->idata = (Mat_int *) malloc( matPtr->len * sizeof ( Mat_int ) );
    }

    void redim( int nx, int ny, int nz )
    {
        free( matPtr->idata );
        matPtr->dim   = 3;
        matPtr->n[0]  = nx;
        matPtr->n[1]  = ny;
        matPtr->n[2]  = nz;
        matPtr->len   = nx * ny * nz;
        matPtr->idata = (Mat_int *) malloc( matPtr->len * sizeof ( Mat_int ) );
    }

    Mat_int& operator() ( int i )
    {
        tMat_Assert( matPtr->dim == 1, "Wrong number of indicies." );
        tMat_Assert( i >= 0 && i < matPtr->n[0],
            "Out of bounds reference" );

        return matPtr->idata[i];
    }

    Mat_int& operator() ( int i, int j )
    {
        tMat_Assert( matPtr->dim == 2, "Wrong number of indicies." );
        tMat_Assert( i >= 0 && i < matPtr->n[0] &&
            j >= 0 && j < matPtr->n[1],
            "Out of bounds reference" );

        return matPtr->idata[I2D( i, j )];
    }

    Mat_int& operator() ( int i, int j, int k )
    {
        tMat_Assert( matPtr->dim == 3, "Wrong number of indicies." );
        tMat_Assert( i >= 0 && i < matPtr->n[0] &&
            j >= 0 && j < matPtr->n[1] &&
            k >= 0 && k < matPtr->n[2],
            "Out of bounds reference" );

        return matPtr->idata[I3D( i, j, k )];
    }
};

#ifndef TCL_NO_UNDEF

#ifdef NO_XCPT
#undef NO_XCPT
#undef try
#undef throw
#undef Throw
#undef catch
#endif

#endif

#undef tMat_Assert

extern "C" {
//--------------------------------------------------------------------------
#endif

// Tcl package initialisation function

int PLDLLIMPEXP_TCLMAT Matrix_Init( Tcl_Interp* );

// This procedure is invoked to process the "matrix" Tcl command.

int
Tcl_MatrixCmd( ClientData clientData, Tcl_Interp *interp,
               int argc, const char **argv );

// Returns a pointer to the specified matrix operator's data.

tclMatrix PLDLLIMPEXP_TCLMAT *
Tcl_GetMatrixPtr( Tcl_Interp *interp, const char *matName );

// Some stuff for handling extension subcommands.

typedef int ( *tclMatrixXtnsnProc )( tclMatrix *pm, Tcl_Interp *interp,
                                     int argc, const char *argv[] );

typedef struct tclMatrixXtnsnDescr
{
    char *cmd;
    tclMatrixXtnsnProc cmdproc;
    struct tclMatrixXtnsnDescr *next;
} tclMatrixXtnsnDescr;

int PLDLLIMPEXP_TCLMAT Tcl_MatrixInstallXtnsn( const char *cmd, tclMatrixXtnsnProc proc );

#ifdef __cplusplus
}
#endif

#endif  // __TCLMATRIX_H__