Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phy-exp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
recolic-hust
phy-exp
Commits
3f790091
There was an error fetching the commit references. Please try again later.
Unverified
Commit
3f790091
authored
7 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
Add inverse
parent
446a96fd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
__pycache__/quickmap.cpython-36.pyc
+0
-0
0 additions, 0 deletions
__pycache__/quickmap.cpython-36.pyc
quickmap.py
+16
-7
16 additions, 7 deletions
quickmap.py
test.py
+1
-2
1 addition, 2 deletions
test.py
with
17 additions
and
9 deletions
__pycache__/quickmap.cpython-36.pyc
+
0
−
0
View file @
3f790091
No preview for this file type
This diff is collapsed.
Click to expand it.
quickmap.py
+
16
−
7
View file @
3f790091
...
...
@@ -17,10 +17,11 @@ def dotMultiply(vctA, vctB):
ans
+=
a
*
b
return
ans
def
GetMap
(
parrX
,
parrY
,
windowSizeX
=
12
,
windowSizeY
=
8
,
extendXRate
=
1
,
line
=
False
,
passO
=
False
,
maxXPower
=
1
):
def
GetMap
(
parrX
,
parrY
,
windowSizeX
=
12
,
windowSizeY
=
8
,
extendXRate
=
1
,
extendYRate
=
1
,
line
=
False
,
passO
=
False
,
maxXPower
=
1
,
inverseK
=
False
):
print
(
'
Generic-GetMap by Recolic.
'
)
arrX
,
arrY
=
parrX
,
parrY
maxX
=
max
(
arrX
)
*
extendXRate
maxX
,
maxY
=
max
(
arrX
)
*
extendXRate
,
max
(
arrY
)
*
extendYRate
minX
,
minY
=
min
(
arrX
)
*
extendXRate
,
min
(
arrY
)
*
extendYRate
# Do calculate
# y = [k0 k1 k2 ...] dot [x^0 x^1 x^2 ...]
print
(
'
Your input:
'
,
arrX
,
'
|
'
,
arrY
)
...
...
@@ -33,14 +34,18 @@ def GetMap(parrX, parrY, windowSizeX=12, windowSizeY=8, extendXRate=1, line=Fals
vctX
[
0
]
=
0
return
dotMultiply
(
k
,
vctX
)
def
lossFunc
(
k
,
x
,
y
):
return
lineFunc
(
k
,
x
)
-
y
def
lossFunc
(
k
,
x
,
y
):
return
abs
(
lineFunc
(
k
,
x
)
-
y
)
# Fire!
if
line
:
kInit
=
[
1
for
_
in
range
(
maxXPower
+
1
)]
kInit
[
0
]
=
0
# guarantee passO.
kFinal
,
_
=
leastsq
(
lossFunc
,
kInit
,
args
=
(
X
,
Y
))
print
(
'
Fit line done. k=
'
,
kFinal
)
if
inverseK
:
kFinal
,
_
=
leastsq
(
lossFunc
,
kInit
,
args
=
(
Y
,
X
))
print
(
'
Fit line done. k^-1=
'
,
kFinal
)
else
:
kFinal
,
_
=
leastsq
(
lossFunc
,
kInit
,
args
=
(
X
,
Y
))
print
(
'
Fit line done. k=
'
,
kFinal
)
else
:
print
(
'
Drawing map without fitting a line...
'
)
...
...
@@ -51,8 +56,12 @@ def GetMap(parrX, parrY, windowSizeX=12, windowSizeY=8, extendXRate=1, line=Fals
plt
.
figure
(
figsize
=
(
windowSizeX
,
windowSizeY
))
plt
.
scatter
(
X
,
Y
,
color
=
"
red
"
,
label
=
"
Sample Point
"
,
linewidth
=
3
)
if
line
:
px
=
numpy
.
linspace
(
0
,
maxX
,
1000
)
py
=
dotMultiply
(
kFinal
,
[
px
**
power
for
power
in
range
(
maxXPower
+
1
)])
if
inverseK
:
py
=
numpy
.
linspace
(
minY
,
maxY
,
1000
)
px
=
dotMultiply
(
kFinal
,
[
py
**
power
for
power
in
range
(
maxXPower
+
1
)])
else
:
px
=
numpy
.
linspace
(
minX
,
maxX
,
1000
)
py
=
dotMultiply
(
kFinal
,
[
px
**
power
for
power
in
range
(
maxXPower
+
1
)])
plt
.
plot
(
px
,
py
,
color
=
"
orange
"
,
label
=
"
Fitting Line
"
,
linewidth
=
2
)
plt
.
legend
()
plt
.
grid
()
...
...
This diff is collapsed.
Click to expand it.
test.py
+
1
−
2
View file @
3f790091
...
...
@@ -3,6 +3,5 @@ import quickmap
yrc
=
[
-
6.77
,
-
6.78
,
-
6.78
,
-
6.76
,
-
6.73
,
-
6.73
,
-
6.72
,
-
6.70
,
-
6.69
,
-
6.67
,
-
6.60
,
-
6.45
,
-
6.37
,
-
6.20
,
-
5.99
,
-
5.77
,
-
5.45
,
-
5.07
,
-
3.52
,
-
2.87
,
-
2.36
,
-
2.08
,
-
1.77
,
-
1.55
,
-
1.40
,
-
1.26
,
-
0.97
,
-
0.84
,
-
0.64
]
xrc
=
[
0.0
,
2.0
,
4.0
,
10.0
,
20.0
,
22.0
,
25.0
,
30.0
,
33.0
,
35.0
,
37.0
,
38.0
,
38.5
,
39.0
,
39.6
,
40.0
,
40.5
,
41.0
,
43.0
,
44.0
,
45.0
,
46.0
,
47.0
,
48.0
,
49.0
,
50.0
,
53.0
,
55.0
,
60.0
]
for
i
in
range
(
15
):
quickmap
.
GetMap
(
xrc
,
yrc
,
line
=
True
,
maxXPower
=
i
,
extendXRate
=
1
)
quickmap
.
GetMap
(
xrc
,
yrc
,
line
=
True
,
maxXPower
=
16
,
inverseK
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment