IsLinearlyIndependent: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
K (→JUnit Tests) |
||
(13 dazwischenliegende Versionen von 4 Benutzern werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
===Zugehörige Evaluatoren=== | |||
*'''MathEvaluator''' | |||
===Beschreibung=== | ===Beschreibung=== | ||
Die Funktion ''isLinearlyIndependent'' testet, ob Vektoren linear unabhägig sind. Die Funktion erwartet eine | Die Funktion ''isLinearlyIndependent'' testet, ob Vektoren linear unabhägig sind. Die Funktion erwartet eine Liste von Vektoren und gibt einen [[Boolean]] zurück. | ||
===Syntax=== | ===Syntax=== | ||
isLinearlyIndependent( | isLinearlyIndependent([[List]] liste) | ||
===Parameter=== | ===Parameter=== | ||
* '''vektoren''' - | * '''vektoren''' - [[List]] von [[Vektor]], die auf lineare Unabhängigkeit geprüft werden sollen | ||
===Return Value=== | ===Return Value=== | ||
* Gibt einen | * Gibt einen [[Boolean]] zurück | ||
===Beispiele=== | ===Beispiele=== | ||
isLinearlyIndependent( | isLinearlyIndependent(list(vector(1,1), vector(1,2))) --> returns ''true'' | ||
====JUnit Tests==== | ====JUnit Tests==== | ||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed"> | <span class="mw-customtoggle-myDivision">[Anzeigen]</span> | ||
@ | <syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | ||
public void beforeTest(){ | @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 | @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> | ||
[[Kategorie:Math-Evaluatorfunktion]][[Kategorie:Testfunktionen]][[Kategorie:Listfunktionen]][[Kategorie:lineare Algebra]][[Kategorie:JACK2]][[Kategorie:JACK3]] | |||
[[Kategorie: |
Aktuelle Version vom 18. April 2024, 12:50 Uhr
Zugehörige Evaluatoren
- MathEvaluator
Beschreibung
Die Funktion isLinearlyIndependent testet, ob Vektoren linear unabhägig sind. Die Funktion erwartet eine Liste von Vektoren und gibt einen Boolean zurück.
Syntax
isLinearlyIndependent(List liste)
Parameter
Return Value
- Gibt einen Boolean zurück
Beispiele
isLinearlyIndependent(list(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();
}