This file is indexed.

/usr/lib/ats-anairiats-0.2.11/libats/SATS/fmatrix.sats is in ats-lang-anairiats 0.2.11-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
(***********************************************************************)
(*                                                                     *)
(*                         Applied Type System                         *)
(*                                                                     *)
(*                              Hongwei Xi                             *)
(*                                                                     *)
(***********************************************************************)

(*
** ATS - Unleashing the Potential of Types!
** Copyright (C) 2002-2009 Hongwei Xi, Boston University
** All rights reserved
**
** ATS 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.1, or (at your option) any later
** version.
** 
** ATS 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  ATS;  see  the  file  COPYING.  If not, write to the Free
** Software Foundation, 51  Franklin  Street,  Fifth  Floor,  Boston,  MA
** 02110-1301, USA.
*)

(* ****** ****** *)

(*
**
** Fortran matrices: column-major representation
**
** Contributed by Hongwei Xi (hwxi AT cs DOT bu DOT edu)
** Contributed by Shivkumar Chandrasekaran (shiv AT ece DOT ucsb DOT edu)
**
** Time: Summer, 2009
**
*)

(* ****** ****** *)

//
// License: LGPL 3.0 (available at http://www.gnu.org/licenses/lgpl.txt)
//

(* ****** ****** *)

%{#
#include "libats/CATS/fmatrix.cats"
%} // end of [%{#]

(* ****** ****** *)

staload "libats/SATS/genarrays.sats"

(* ****** ****** *)
//
// HX: [fmatrix] is column-major
//
absviewt@ype
fmatrix_viewt0ype_int_int_viewt0ype
  (a:viewt@ype+,row:int,col:int) = @[@[a][row]][col]
stadef fmatrix =
  fmatrix_viewt0ype_int_int_viewt0ype

viewdef
fmatrix_v (
  a:viewt@ype, row:int, col:int, l:addr
) = fmatrix (a, row, col) @ l

(* ****** ****** *)

prfun array_v_of_fmatrix_v
  {a:viewt@ype} {m,n:int} {l:addr}
  (pf_mat: fmatrix_v (a, m, n, l))
  :<> [mn:int] (MUL (m, n, mn), array_v (a, mn, l))
// end of [array_v_of_fmatrix_v]

prfun fmatrix_v_of_array_v
  {a:viewt@ype} {m,n:int} {mn:int} {l:addr}
  (pf_mul: MUL (m, n, mn), pf_arr: array_v (a, mn, l))
  :<> fmatrix_v (a, m, n, l)
// end of [fmatrix_v_of_array_v]

(* ****** ****** *)

fun{a:viewt@ype}
fmatrix_ptr_alloc
  {m,n:nat} (
  m: size_t m, n: size_t n
) :<> [mn:nat] [l:agz] (
  free_gc_v (a?, mn, l)
, MUL (m, n, mn)
, fmatrix_v (a?, m, n, l)
| ptr l
) // end of [fmatrix_ptr_alloc]

(* ****** ****** *)

fun fmatrix_ptr_free
  {a:t@ype}
  {m,n,mn:nat} {l:addr} (
  pf_gc: free_gc_v (a, mn, l)
, pf_mn: MUL (m, n, mn)
, pf_fmat: fmatrix_v (a, m, n, l)
| p: ptr l
) :<> void // end of [fmatrix_ptr_free]

(* ****** ****** *)

fun{a:viewt@ype}
fmatrix_ptr_allocfree
  {m,n:nat} (
  m: size_t m, n: size_t n
) :<> [l:agz] (
  fmatrix_v (a?, m, n, l)
| ptr l, (fmatrix_v (a?, m, n, l) | ptr l) -<lin> void
) // end of [fmatrix_ptr_allocfree]

(* ****** ****** *)

fun{a:t@ype}
fmatrix_ptr_initialize_elt
  {m,n:nat} {l:addr} (
  base: &fmatrix (a?, m, n) >> fmatrix (a, m, n)
, m: size_t m, n: size_t n, x: a
) :<> void // end of [fmatrix_initialize_elt]

(* ****** ****** *)

fun{a:viewt@ype}
fmatrix_ptr_initialize_vclo
  {v:view} {m,n:nat} (
  pf: !v 
| base: &fmatrix (a?, m, n) >> fmatrix (a, m, n)
, m: size_t m, n: size_t n
, f: &(!v | &(a?) >> a, sizeLt m, sizeLt n) -<clo> void
) :<> void // end of [fmatrix_ptr_initialize_vclo]

(* ****** ****** *)

fun{a:viewt@ype}
fmatrix_ptr_takeout
  {m,n:int}
  {i,j:nat | i < m; j < n}
  {l0:addr} (
  pf_mat: fmatrix_v (a, m, n, l0)
| base: ptr l0
, m: size_t m
, i: size_t i, j: size_t j
) :<> [l:addr] (
  a @ l
, a @ l -<lin,prf> fmatrix_v (a, m, n, l0)
| ptr l
) // end of [fmatrix_ptr_takeout]

(* ****** ****** *)

fun{a:t@ype}
fmatrix_ptr_get_elt_at
  {m,n:int} {i,j:nat | i < m; j < n} (
  base: &fmatrix (a, m, n), m: size_t m, i: size_t i, j: size_t j
) :<> a // end of [fmatrix_ptr_ptr_get_elt_at]

fun{a:t@ype}
fmatrix_ptr_set_elt_at
  {m,n:int} {i,j:nat | i < m; j < n} (
  base: &fmatrix (a, m, n), m: size_t m, i: size_t i, j: size_t j, x: a
) :<> void // end of [fmatrix_ptr_ptr_set_elt_at]

overload [] with fmatrix_ptr_get_elt_at
overload [] with fmatrix_ptr_set_elt_at

(* ****** ****** *)

fun{a:t@ype}
fmatrix_ptr_copy {m,n:nat} (
  A: &fmatrix(a, m, n)
, B: &fmatrix(a?, m, n) >> fmatrix(a, m, n)
, m: size_t m, n: size_t n
) : void // end of [fmatrix_ptr_copy]

(* ****** ****** *)

prfun GEVEC_v_of_fmatrix_v
  {a1:viewt@ype} {m,n:nat} {mn:int} {l:addr} (
  pf_mul: MUL (m, n, mn), pf_mat: fmatrix_v (a1, m, n, l)
) :<> (
  GEVEC_v (a1, mn, 1, l)
, {a2:viewt@ype | a1 \tszeq a2}
    GEVEC_v (a2, mn, 1, l) -<prf> fmatrix_v (a2, m, n, l)
  // [fpf: for going back]
) // end of [GEVEC_v_of_fmatrix_v]

(*
// this kind of destroys the genericity of GEVEC
prfun fmatrix_v_of_GEVEC_v_of
  {a:viewt@ype} {m,n:nat} {mn:int} {l:addr} (
  pf_mul: MUL (m, n, mn), pf_mat: GEVEC_v (a, mn, 1, l)
) :<> (
  fmatrix_v (a, m, n, l)
, fmatrix_v (a, m, n, l) -<prf> GEVEC_v (a, mn, 1, l)
) // end of [GEVEC_v_of_fmatrix_v]
*)

(* ****** ****** *)

prfun GEMAT_v_of_fmatrix_v
  {a1:viewt@ype} {m,n:nat} {l:addr} (
  pf_mat: fmatrix_v (a1, m, n, l)
) :<> (
  GEMAT_v (a1, m, n, col, m, l)
, {a2:viewt@ype | a1 \tszeq a2}
    GEMAT_v (a2, m, n, col, m, l) -<prf> fmatrix_v (a2, m, n, l)
  // [fpf: for going back]
) // end of [GEMAT_v_of_fmatrix_v]

(*
// this kind of destroys the genericity of GEMAT
prfun fmatrix_v_of_GEMAT_v
  {a:viewt@ype} {m,n:nat} {l:addr} (
  pf_mat: GEMAT_v (a, m, n, col, m, l)
) :<> (
  fmatrix_v (a, m, n, l)
, fmatrix_v (a, m, n, l) -<prf> GEMAT_v (a, m, n, col, m, l)
) // end of [GEMAT_v_of_fmatrix_v]
*)

(* ****** ****** *)

prfun GBMAT_v_of_fmatrix_v
  {a:viewt@ype} {m,n,k,kl,ku:nat| k == kl+ku+1} {l:addr} (
  pf : fmatrix_v (a, k, n, l), m : size_t m, kl : size_t kl, ku : size_t ku
) :<> (
  GBMAT_v (a, m, n, col, kl, ku, k, l)
, GBMAT_v (a, m, n, col, kl, ku, k, l) -<prf> fmatrix_v (a, k, n, l)
) // end of [GEBAT_v_of_fmatrix_v]

(* ****** ****** *)

fun fmatrix_ptr_foreach_funenv_tsz
  {a:viewt@ype}
  {v:view} {vt:viewtype}
  {ord:order} {m,n:nat} (
  pf: !v
| M: &fmatrix (a, m, n)
, f: (!v | &a, !vt) -<fun> void
, ord: ORDER ord, m: size_t m, n: size_t n
, tsz: sizeof_t a
, env: !vt
) :<> void // end of [fmatrix_foreach_funenv_tsz]

fun{a:viewt@ype}
fmatrix_ptr_foreach_fun {ord:order} {m,n:nat} (
  M: &fmatrix (a, m, n)
, f: (&a) -<fun> void
, ord: ORDER ord, m: size_t m, n: size_t n
) :<> void // end of [fmatrix_foreach_fun]

fun{a:viewt@ype}
fmatrix_ptr_foreach_vclo {v:view} {ord:order} {m,n:nat} (
  pf: !v
| M: &fmatrix (a, m, n)
, f: &(!v | &a) -<clo> void
, ord: ORDER ord, m: size_t m, n: size_t n
) :<> void // end of [fmatrix_foreach_vclo]

(* ****** ****** *)

fun fmatrix_ptr_iforeach_funenv_tsz
  {a:viewt@ype}
  {v:view} {vt:viewtype}
  {ord:order} {m,n:nat} (
  pf: !v
| M: &fmatrix (a, m, n)
, f: (!v | sizeLt m, sizeLt n, &a, !vt) -<fun> void
, ord: ORDER ord, m: size_t m, n: size_t n
, tsz: sizeof_t a
, env: !vt
) :<> void // end of [fmatrix_iforeach_funenv_tsz]

fun{a:viewt@ype}
fmatrix_ptr_iforeach_fun
  {ord:order} {m,n:nat} (
  M: &fmatrix (a, m, n), f: (sizeLt m, sizeLt n, &a) -<fun> void
, ord: ORDER ord, m: size_t m, n: size_t n
) :<> void // end of [fmatrix_iforeach_fun]

fun{a:viewt@ype}
fmatrix_ptr_iforeach_vclo {v:view} {ord:order} {m,n:nat} (
  pf: !v
| M: &fmatrix (a, m, n), f: &(!v | sizeLt m, sizeLt n, &a) -<clo> void
, ord: ORDER ord, m: size_t m, n: size_t n
) :<> void // end of [fmatrix_iforeach_vclo]

(* ****** ****** *)

(* end of [fmatrix.sats] *)