~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/fftw/genfft-k7/variable.ml

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(*
 
2
 * Copyright (c) 1997-1999 Massachusetts Institute of Technology
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 *
 
18
 *)
 
19
 
 
20
(* Data types and functions for dealing with variables in symbolic
 
21
 * expressions and the abstract syntax tree. *)
 
22
 
 
23
(* Variables fall into one of four categories: temporary variables
 
24
 * (which the generator can add or delete at will), named (fixed)
 
25
 * variables, and the real/imaginary parts of complex arrays.  Arrays
 
26
 * can be either input arrays, output arrays, or arrays of precomputed
 
27
 * twiddle factors (roots of unity). *)
 
28
 
 
29
type array = Input | Output | Twiddle
 
30
 
 
31
let arrayToString = function 
 
32
  | Input   -> "in" 
 
33
  | Output  -> "out" 
 
34
  | Twiddle -> "tw"
 
35
 
 
36
type variable =
 
37
  | Temporary of int
 
38
  | Named of string
 
39
  | RealArrayElem of (array * int)
 
40
  | ImagArrayElem of (array * int)
 
41
 
 
42
let make_temporary =
 
43
  let tmp_count = ref 0
 
44
  in fun () -> begin
 
45
    tmp_count := !tmp_count + 1;
 
46
    Temporary !tmp_count
 
47
  end
 
48
 
 
49
let is_temporary = function
 
50
  | Temporary _ -> true
 
51
  | _ -> false
 
52
 
 
53
let is_real = function
 
54
  | RealArrayElem _ -> true
 
55
  | _ -> false
 
56
 
 
57
let is_imag = function
 
58
  | ImagArrayElem _ -> true
 
59
  | _ -> false
 
60
 
 
61
let is_output = function
 
62
  | RealArrayElem (Output, _) -> true
 
63
  | ImagArrayElem (Output, _) -> true
 
64
  | _ -> false
 
65
 
 
66
let is_input = function
 
67
  | RealArrayElem (Input, _) -> true
 
68
  | ImagArrayElem (Input, _) -> true
 
69
  | _ -> false
 
70
 
 
71
let is_twiddle = function
 
72
  | RealArrayElem (Twiddle, _) -> true
 
73
  | ImagArrayElem (Twiddle, _) -> true
 
74
  | _ -> false
 
75
 
 
76
let is_locative x = (is_input x) || (is_output x)
 
77
let is_constant = is_twiddle
 
78
 
 
79
let same = (=)
 
80
 
 
81
let hash = function
 
82
  | RealArrayElem(Input,i)   ->  i * 8
 
83
  | ImagArrayElem(Input,i)   -> -i * 8 + 1
 
84
  | RealArrayElem(Output,i)  ->  i * 8 + 2
 
85
  | ImagArrayElem(Output,i)  -> -i * 8 + 3
 
86
  | RealArrayElem(Twiddle,i) ->  i * 8 + 4
 
87
  | ImagArrayElem(Twiddle,i) -> -i * 8 + 5
 
88
  | _ -> 0
 
89
  
 
90
let similar a b = 
 
91
  same a b ||
 
92
  (match (a, b) with
 
93
     | (RealArrayElem (a1, k1), ImagArrayElem (a2, k2)) -> a1 = a2 && k1 = k2
 
94
     | (ImagArrayElem (a1, k1), RealArrayElem (a2, k2)) -> a1 = a2 && k1 = k2
 
95
     | _ -> false)
 
96
    
 
97
(* true if assignment of a clobbers variable b *)
 
98
let clobbers a b = match (a, b) with
 
99
  | (RealArrayElem (Output, k1), RealArrayElem (Input, k2)) -> k1 = k2
 
100
  | (ImagArrayElem (Output, k1), ImagArrayElem (Input, k2)) -> k1 = k2
 
101
  | _ -> false
 
102
 
 
103
(* true if a is the real part and b the imaginary of the same array *)
 
104
let real_imag a b = match (a, b) with
 
105
  | (RealArrayElem (a1, k1), ImagArrayElem (a2, k2)) -> a1 = a2 && k1 = k2 
 
106
  | _ -> false
 
107
 
 
108
(* true if a and b are elements of the same array, and a has smaller index *)
 
109
let increasing_indices a b = match (a, b) with
 
110
  | (RealArrayElem (a1, k1), RealArrayElem (a2, k2)) -> a1 = a2 && k1 < k2 
 
111
  | (RealArrayElem (a1, k1), ImagArrayElem (a2, k2)) -> a1 = a2 && k1 < k2 
 
112
  | (ImagArrayElem (a1, k1), RealArrayElem (a2, k2)) -> a1 = a2 && k1 < k2 
 
113
  | (ImagArrayElem (a1, k1), ImagArrayElem (a2, k2)) -> a1 = a2 && k1 < k2 
 
114
  | _ -> false
 
115
 
 
116
let access array k = (RealArrayElem (array, k),  ImagArrayElem (array, k))
 
117
 
 
118
let access_input = access Input
 
119
let access_output = access Output
 
120
let access_twiddle = access Twiddle
 
121
 
 
122
let make_named name = Named name
 
123
 
 
124
let unparse = function
 
125
  | Temporary x -> "T" ^ (string_of_int x)
 
126
  | Named s -> s
 
127
  | RealArrayElem (a, x) -> "Re(" ^ (arrayToString a) ^ "[" ^
 
128
      (string_of_int x) ^ "])"
 
129
  | ImagArrayElem (a, x) -> "Im(" ^ (arrayToString a) ^ "[" ^
 
130
      (string_of_int x) ^ "])"
 
131