Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Dot-product/Rascal/dot-product-1.rascal
Normal file
16
Task/Dot-product/Rascal/dot-product-1.rascal
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import List;
|
||||
|
||||
public int dotProduct(list[int] L, list[int] M){
|
||||
result = 0;
|
||||
if(size(L) == size(M)) {
|
||||
while(size(L) >= 1) {
|
||||
result += (head(L) * head(M));
|
||||
L = tail(L);
|
||||
M = tail(M);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
throw "vector sizes must match";
|
||||
}
|
||||
}
|
||||
12
Task/Dot-product/Rascal/dot-product-2.rascal
Normal file
12
Task/Dot-product/Rascal/dot-product-2.rascal
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import Prelude;
|
||||
|
||||
public real matrixDotproduct(rel[real x, real y, real v] column1, rel[real x, real y, real v] column2){
|
||||
return (0.0 | it + v1*v2 | <x1,y1,v1> <- column1, <x2,y2,v2> <- column2, y1==y2);
|
||||
}
|
||||
|
||||
//a matrix, given by a relation of x-coordinate, y-coordinate, value.
|
||||
public rel[real x, real y, real v] matrixA = {
|
||||
<0.0,0.0,12.0>, <0.0,1.0, 6.0>, <0.0,2.0,-4.0>,
|
||||
<1.0,0.0,-51.0>, <1.0,1.0,167.0>, <1.0,2.0,24.0>,
|
||||
<2.0,0.0,4.0>, <2.0,1.0,-68.0>, <2.0,2.0,-41.0>
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue