Skip to content

Commit

Permalink
apparently all my complex changes from branch didn't make it through …
Browse files Browse the repository at this point in the history
…the merge, or whatever. Re-add some stuff
  • Loading branch information
Whiteknight committed Nov 17, 2009
1 parent e5ddc56 commit 98e5607
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 87 deletions.
30 changes: 0 additions & 30 deletions src/builtins/complex.pir
Expand Up @@ -18,33 +18,3 @@
$P0 = "1i"
.return ($P0)
.end


.sub 'conj'
.param int nargout
.param int nargin
.param pmc x

$S0 = <<"EOS"
.sub '' :anon
.param int nargout
.param int nargin
.param pmc z
$S0 = typeof z
unless $S0 == 'Complex' goto return_conj
$N0 = z["imag"]
$N0 = $N0 * -1
z["imag"] = $N0
return_conj:
.return(z)
.end
EOS

$P0 = compreg "PIR"
$P1 = $P0($S0)
$P2 = $P1[0]
$P3 = '!lookup_function'('arrayfun')
$P4 = $P3(1,1,$P2,x)
.return($P4)
.end

27 changes: 27 additions & 0 deletions src/classes/matrix_row.pir
Expand Up @@ -6,6 +6,7 @@
addattribute $P0, "has_number"
addattribute $P0, "row"
addattribute $P0, "row_length"
addattribute $P0, "has_complex"
.end

.sub 'init' :vtable
Expand All @@ -17,6 +18,8 @@
setattribute self, "has_number", $P0
$P0 = box 0
setattribute self, "row_length", $P0
$P0 = box 0
setattribute self, "has_complex", $P0
.end

.sub 'get_iter' :vtable
Expand Down Expand Up @@ -69,6 +72,22 @@
.return(has_number)
.end

.sub 'has_complex' :method
.param int has_complex :optional
.param int has_has_complex :opt_flag

if has_has_complex goto set_has_complex
$P0 = getattribute self, "has_complex"
$I0 = $P0
.return($I0)

set_has_complex:
$P0 = box has_complex
setattribute self, "has_complex", $P0
.return(has_complex)
.end


.sub 'row_length' :method
$P0 = getattribute self, "row_length"
$I0 = $P0
Expand All @@ -86,10 +105,12 @@
.local pmc arg
.local pmc has_string
.local pmc has_number
.local pmc has_complex
.local int row_length
row_length = 0
has_string = getattribute self, "has_string"
has_number = getattribute self, "has_number"
has_complex = getattribute self, "has_complex"
myiter = iter args
loop_top:
unless myiter goto loop_bottom
Expand All @@ -98,6 +119,7 @@
if $S0 == "Integer" goto has_arg_number
if $S0 == "Float" goto has_arg_number
if $S0 == "String" goto has_arg_string
if $S0 == "Complex" goto has_arg_complex
# TODO: What here?
goto loop_top
has_arg_number:
Expand All @@ -110,6 +132,11 @@
$I0 = length $S0
row_length = row_length + $I0
goto loop_top
has_arg_complex:
has_number = 1
has_complex = 1
inc row_length
goto loop_top

loop_bottom:
setattribute self, "row", args
Expand Down
46 changes: 42 additions & 4 deletions src/internals/aggregates.pir
Expand Up @@ -15,6 +15,8 @@
.param pmc args :slurpy
$P0 = new ['matrix_row']
$P0.'build_row'(args)
$I0 = $P0.'row_length'()
say $I0
.return($P0)
.end

Expand All @@ -24,14 +26,16 @@
# Setup local variables
.local pmc thisrow
.local pmc lengths
.local int numbers
.local int strings
.local int complex
lengths = new ['FixedIntegerArray']
$I0 = ary
lengths = $I0
.local int idx
idx = 0
.local int numbers
numbers = 0
.local int strings
complex = 0
strings = 0
.local pmc myiter
myiter = iter ary
Expand All @@ -44,12 +48,14 @@
numbers = or numbers, $I0
$I0 = thisrow.'has_string'()
strings = or strings, $I0
$I0 = thisrow.'has_complex'()
complex = or complex, $I0
$I0 = thisrow.'row_length'()
lengths[idx] = $I0
inc idx
goto loop_top
loop_bottom:
.return(lengths, numbers, strings)
.return(lengths, numbers, strings, complex)
.end

.sub '!_verify_array_lengths_equal'
Expand Down Expand Up @@ -90,6 +96,31 @@
.return(matrix)
.end

.sub '!_build_complex_matrix'
.param pmc rows
.local pmc matrix
.local int x
.local int y
.local int width
.local int height
matrix = new ['NumMatrix2D']
y = 0
height = rows
$P0 = rows[0]
width = $P0
outer_loop_top:
x = 0
$P0 = rows[y]
inner_loop_top:
$P1 = $P0[x]
matrix[x;y] = $P1
inc x
if x < width goto inner_loop_top
inc y
if y < height goto outer_loop_top
.return(matrix)
.end

.sub '!_build_string_matrix'
.param pmc rows
.local pmc matrix
Expand All @@ -114,6 +145,7 @@
.local pmc lengths
.local int has_numbers
.local int has_strings
.local int has_complex

# If there are no rows, just return an empty matrix
$I0 = ary
Expand All @@ -122,15 +154,21 @@
.return($P0)

construct_the_matrix:
(lengths, has_numbers, has_strings) = '!_get_rows_info'(ary)
(lengths, has_numbers, has_strings, has_complex) = '!_get_rows_info'(ary)
unless has_numbers goto dont_check_length
'!_verify_array_lengths_equal'(lengths)

dont_check_length:
if has_complex goto build_complex_matrix
if has_strings goto build_string_matrix
.tailcall '!_build_numerical_matrix'(ary)
build_string_matrix:
.tailcall '!_build_string_matrix'(ary)
build_complex_matrix:
if has_strings goto cant_have_both
.tailcall '!_build_complex_matrix'(ary)
cant_have_both:
_error_all("Cannot have both complex and string values in one matrix")
.end

.sub '!matrix'
Expand Down
53 changes: 0 additions & 53 deletions t/305-clapack.t

This file was deleted.

0 comments on commit 98e5607

Please sign in to comment.