IsLinearlyIndependent: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 17: | Zeile 17: | ||
<span class="mw-customtoggle-myDivision">[Anzeigen]</span> | <span class="mw-customtoggle-myDivision">[Anzeigen]</span> | ||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | <syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | ||
@ | @BeforeClass | ||
public void beforeTest(){ | public static void beforeTest() { | ||
// set(vector(1,2,3),vector(3,3,3)) | |||
isLinearlyIndependentFillInVariableMap.put(1, OMConverter.toObject( | |||
"<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>")); | |||
isLinearlyIndependentFillInVariableMap.put(2, OMConverter.toObject("<OMOBJ><OMI>1</OMI></OMOBJ>")); | |||
// set(vector(1,2,3),vector(3,3,3)) | |||
isLinearlyIndependentExerciseVariableMap.put("a", OMConverter.toObject( | |||
"<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>")); | |||
isLinearlyIndependentExerciseVariableMap.put("b", OMConverter.toObject("<OMOBJ><OMI>1</OMI></OMOBJ>")); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependent1() { | |||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,1), vector(1,2)))", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependent2() { | |||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1)))", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependent3() { | |||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,1,0), vector(1,1,1)))", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependent4() { | |||
assertTrue(Evaluator.getBooleanResult( | |||
"isLinearlyIndependent(set(vector(1,0,0), vector(1,1,1), vector(1.5, 1.5, 1.8)))", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependent5() { | |||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,2,3), vector(3,3,3)))", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependentWithInput1() { | |||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,[pos=2],0), vector(1,1,[pos=2])))", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testIsLinearlyIndependentWithInput2() { | ||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent('[pos=1]')", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testIsLinearlyIndependentWithVariables1() { | ||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,[var=b],0), vector(1,1,[var=b])))", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | } | ||
@Test | @Test | ||
public void | public void testIsLinearlyIndependentWithVariables2() { | ||
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent('[var=a]')", | |||
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap)); | |||
} | } | ||
@Test(expected= | @Test(expected = ParserException.class) | ||
public void TestIsLinearlyIndependentWithWrongInputONECharacter(){ | public void TestIsLinearlyIndependentWithWrongInputONECharacter() { | ||
Evaluator.getBooleanResult("isLinearlyIndependent(ba)", isLinearlyIndependentExerciseVariableMap, | |||
isLinearlyIndependentFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void testIsLinearlyIndependentWithEmptyStringArgument() { | public void testIsLinearlyIndependentWithEmptyStringArgument() { | ||
Evaluator.getBooleanResult("isLinearlyIndependent('')", isLinearlyIndependentExerciseVariableMap, | |||
isLinearlyIndependentFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testIsLinearlyIndependentWithEmptyArgument() { | public void testIsLinearlyIndependentWithEmptyArgument() { | ||
Evaluator.getBooleanResult("isLinearlyIndependent()", isLinearlyIndependentExerciseVariableMap, | |||
isLinearlyIndependentFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testIsLinearlyIndependentWithoutExerciseVariable() { | public void testIsLinearlyIndependentWithoutExerciseVariable() { | ||
Evaluator.getBooleanResult("isLinearlyIndependent('[var=j]')", isLinearlyIndependentExerciseVariableMap, | |||
isLinearlyIndependentFillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testIsLinearlyIndependentWithoutInput() { | public void testIsLinearlyIndependentWithoutInput() { | ||
Evaluator.getBooleanResult("isLinearlyIndependent('[pos=42]')", isLinearlyIndependentExerciseVariableMap, | |||
isLinearlyIndependentFillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 18. September 2017, 12:03 Uhr
Beschreibung
Die Funktion isLinearlyIndependent testet, ob Vektoren linear unabhägig sind. Die Funktion erwartet eine Menge von Vektoren und gibt einen boolean zurück.
Syntax
isLinearlyIndependent(String vektoren)
Parameter
- vektoren - Menge von Vektoren, die auf lineare Unabhängigkeit geprüft werden sollen
Return Value
- Gibt einen boolean zurück
Beispiele
isLinearlyIndependent(set(vector(1,1), vector(1,2))) --> returns true
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
// set(vector(1,2,3),vector(3,3,3))
isLinearlyIndependentFillInVariableMap.put(1, OMConverter.toObject(
"<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"));
isLinearlyIndependentFillInVariableMap.put(2, OMConverter.toObject("<OMOBJ><OMI>1</OMI></OMOBJ>"));
// set(vector(1,2,3),vector(3,3,3))
isLinearlyIndependentExerciseVariableMap.put("a", OMConverter.toObject(
"<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"));
isLinearlyIndependentExerciseVariableMap.put("b", OMConverter.toObject("<OMOBJ><OMI>1</OMI></OMOBJ>"));
}
@Test
public void testIsLinearlyIndependent1() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,1), vector(1,2)))",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependent2() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1)))",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependent3() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,1,0), vector(1,1,1)))",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependent4() {
assertTrue(Evaluator.getBooleanResult(
"isLinearlyIndependent(set(vector(1,0,0), vector(1,1,1), vector(1.5, 1.5, 1.8)))",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependent5() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,2,3), vector(3,3,3)))",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependentWithInput1() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,[pos=2],0), vector(1,1,[pos=2])))",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependentWithInput2() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent('[pos=1]')",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependentWithVariables1() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,[var=b],0), vector(1,1,[var=b])))",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test
public void testIsLinearlyIndependentWithVariables2() {
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent('[var=a]')",
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
@Test(expected = ParserException.class)
public void TestIsLinearlyIndependentWithWrongInputONECharacter() {
Evaluator.getBooleanResult("isLinearlyIndependent(ba)", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testIsLinearlyIndependentWithEmptyStringArgument() {
Evaluator.getBooleanResult("isLinearlyIndependent('')", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testIsLinearlyIndependentWithEmptyArgument() {
Evaluator.getBooleanResult("isLinearlyIndependent()", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testIsLinearlyIndependentWithoutExerciseVariable() {
Evaluator.getBooleanResult("isLinearlyIndependent('[var=j]')", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testIsLinearlyIndependentWithoutInput() {
Evaluator.getBooleanResult("isLinearlyIndependent('[pos=42]')", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}