package org.jlinalg.demo; import org.jlinalg.FieldElement; import org.jlinalg.FieldP; import org.jlinalg.Matrix; import org.jlinalg.Vector; /** * This demonstration of the class FieldP shows that in vector spaces over * finite fields there can be linear dependent vectors which are all orthogonal * to each other. * * @author Andreas Lochbihler */ public class FieldPDemo { public static void main(String[] args) { int prime = 7; FieldElement p1, p2, p3, p4, p5, p6; p1 = new FieldP(1, prime); p2 = new FieldP(2, prime); p3 = new FieldP(3, prime); p4 = new FieldP(4, prime); p5 = new FieldP(5, prime); p6 = new FieldP(6, prime); Vector u = new Vector(new FieldElement[] { p1, p1, p5 }); Vector v = new Vector(new FieldElement[] { p1, p3, p2 }); Vector w = new Vector(new FieldElement[] { p6, p4, p5, }); Matrix matrix = new Matrix(new Vector[] { u, v, w }); System.out.println(matrix); /* * Now we will see that the vectors are linear dependent, because the * rank of the their matrix is smaller than 3. */ System.out.println("Rank: " + matrix.rank()); /* * Let us check now, if they are all orthogonal to each other. Two * vectors a, b are orthogonal on each other if = 0, where < , > * is the scalar product. */ // = System.out.println(" < " + u + ", " + v + " > = " + u.multiply(v)); // = System.out.println(" < " + u + ", " + w + " > = " + u.multiply(w)); // = System.out.println(" < " + v + ", " + w + " > = " + v.multiply(w)); } }