Add Matrix exampel
This commit is contained in:
parent
eb2ae1eb34
commit
e0a531a3a7
42
aspUnify.tex
42
aspUnify.tex
@ -77,6 +77,48 @@ Java has adopted more and more type inference features over time.
|
||||
Currently Java only has local type inference.
|
||||
We want to bring type inference for Java to the next level.
|
||||
|
||||
Our type inference algorithm for Java should be able to retrieve missing type annotations
|
||||
in a Java program.
|
||||
The main difference from existing type inference algorithms for Java is that we also allow method types to be omitted in the input program.
|
||||
|
||||
\begin{figure}
|
||||
\begin{lstlisting}
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
public Matrix(vv) {
|
||||
Integer i;
|
||||
i = 0;
|
||||
while(i < vv.size()) {
|
||||
this.add(vv.elementAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
public mul(m) {
|
||||
var ret = new Matrix();
|
||||
var i = 0;
|
||||
while(i < size()) {
|
||||
var v1 = this.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.get(k)
|
||||
* m.get(k).get(j);
|
||||
k++; }
|
||||
v2.addElement(erg);
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
\end{lstlisting}
|
||||
\end{figure}
|
||||
|
||||
\section{Subtyping}
|
||||
\begin{mathpar}
|
||||
\inferrule[Refl]{}{
|
||||
|
Loading…
Reference in New Issue
Block a user