Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
7e9c9993
Commit
7e9c9993
authored
May 05, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Relative precedences in strategy now support more than 2 functions in the same list.
parent
08c982bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
src/rules/precedences.py
src/rules/precedences.py
+9
-1
src/strategy.py
src/strategy.py
+3
-5
No files found.
src/rules/precedences.py
View file @
7e9c9993
...
@@ -7,12 +7,13 @@ from .logarithmic import factor_in_exponent_multiplicant, \
...
@@ -7,12 +7,13 @@ from .logarithmic import factor_in_exponent_multiplicant, \
from
.derivatives
import
chain_rule
from
.derivatives
import
chain_rule
from
.negation
import
double_negation
,
negated_factor
,
negated_nominator
,
\
from
.negation
import
double_negation
,
negated_factor
,
negated_nominator
,
\
negated_denominator
,
negated_zero
negated_denominator
,
negated_zero
from
.factors
import
expand_double
,
expand_single
from
.fractions
import
multiply_with_fraction
,
extract_fraction_terms
,
\
from
.fractions
import
multiply_with_fraction
,
extract_fraction_terms
,
\
add_nominators
add_nominators
from
.integrals
import
factor_out_constant
,
integrate_variable_root
from
.integrals
import
factor_out_constant
,
integrate_variable_root
from
.powers
import
remove_power_of_one
from
.powers
import
remove_power_of_one
from
.sqrt
import
quadrant_sqrt
,
extract_sqrt_mult_priority
from
.sqrt
import
quadrant_sqrt
,
extract_sqrt_mult_priority
from
.lineq
import
substitute_variable
,
swap_sides
from
.lineq
import
substitute_variable
,
swap_sides
,
divide_term
,
multiply_term
# Functions to move to the beginning of the possibilities list. Pairs of within
# Functions to move to the beginning of the possibilities list. Pairs of within
...
@@ -32,6 +33,9 @@ HIGH = [
...
@@ -32,6 +33,9 @@ HIGH = [
LOW
=
[
LOW
=
[
factor_in_exponent_multiplicant
,
factor_in_exponent_multiplicant
,
reduce_fraction_constants
,
reduce_fraction_constants
,
# Sorting expression terms has a low priority because it is assumed to
# be handled by the user
move_constant
,
move_constant
,
]
]
...
@@ -68,6 +72,10 @@ RELATIVE = [
...
@@ -68,6 +72,10 @@ RELATIVE = [
# Prevent useless swapping when solving multiple equations
# Prevent useless swapping when solving multiple equations
(
substitute_variable
,
swap_sides
),
(
substitute_variable
,
swap_sides
),
# When solving of an equation with constants, expanding an equation has
# a lower priority
(
divide_term
,
multiply_term
,
swap_sides
,
expand_double
,
expand_single
),
]
]
...
...
src/strategy.py
View file @
7e9c9993
...
@@ -18,11 +18,9 @@ def compare_possibilities(a, b):
...
@@ -18,11 +18,9 @@ def compare_possibilities(a, b):
return
0
return
0
# Check if A and B have a precedence relative to eachother
# Check if A and B have a precedence relative to eachother
if
(
ha
,
hb
)
in
RELATIVE
:
for
rel
in
RELATIVE
:
return
-
1
if
ha
in
rel
and
hb
in
rel
:
return
cmp
(
rel
.
index
(
ha
),
rel
.
index
(
hb
))
if
(
hb
,
ha
)
in
RELATIVE
:
return
1
# If A has a high priority, it might be moved to the start of the list
# If A has a high priority, it might be moved to the start of the list
if
ha
in
HIGH
:
if
ha
in
HIGH
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment