projects
/
pytorch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e916a86
)
Update.
author
Francois Fleuret
<francois@fleuret.org>
Fri, 10 Apr 2020 21:31:15 +0000
(23:31 +0200)
committer
Francois Fleuret
<francois@fleuret.org>
Fri, 10 Apr 2020 21:31:15 +0000
(23:31 +0200)
poly.py
patch
|
blob
|
history
diff --git
a/poly.py
b/poly.py
index
818742b
..
1b157a8
100755
(executable)
--- a/
poly.py
+++ b/
poly.py
@@
-19,6
+19,10
@@
def pol_prod(a, b):
q = (kk == torch.arange(a.size(0) + b.size(0) - 1)[None, :])
return (mm * q).sum(0)
+def pol_eval(a, x):
+ d = torch.arange(a.size(0))
+ return (x[:, None].pow(d[None, :]) * a[None, :]).sum(1)
+
def pol_prim(a):
n = torch.arange(a.size(0) + 1).float()
n[1:] = a / n[1:]
@@
-31,3
+35,4
@@
if __name__ == '__main__':
b = torch.tensor([2., 5.])
print(pol_prod(a, b))
print(pol_prim(b))
+ print(pol_eval(a, torch.tensor([0.0, 1.0, 2.0])))