IsLinearlyIndependent: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 13: | Zeile 13: | ||
===Beispiele=== | ===Beispiele=== | ||
isLinearlyIndependent(set(vector(1,1), vector(1,2))) --> returns true | isLinearlyIndependent(set(vector(1,1), vector(1,2))) --> returns true | ||
====JUnit Tests==== | |||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed"> | |||
@Before | |||
public void beforeTest(){ | |||
placeFillInVariable(1,new OpenMathObject() { | |||
//[vector(QQ,[1,2,3]),vector(QQ,[3,3,3])] | |||
@Override | |||
protected String getPartialXML() { | |||
return "<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>"; | |||
} | |||
}); | |||
placeFillInVariable(2, OMParser.parse("1")); | |||
placeExerciseVariable("a", new OpenMathObject() { | |||
//[vector(QQ,[1,2,3]),vector(QQ,[3,3,3])] | |||
@Override | |||
protected String getPartialXML() { | |||
return "<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>"; | |||
} | |||
}); | |||
placeExerciseVariable("b", OMParser.parse("1")); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependent(){ | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,1), vector(1,2)))")); | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1)))")); | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,1,0), vector(1,1,1)))")); | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,0,0), vector(1,1,1), vector(1.5, 1.5, 1.8)))")); | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,2,3), vector(3,3,3)))")); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependentWithInput(){ | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,[pos=2],0), vector(1,1,[pos=2])))")); | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent('[pos=1]')")); | |||
} | |||
@Test | |||
public void testIsLinearlyIndependentWithVariables(){ | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,[var=b],0), vector(1,1,[var=b])))")); | |||
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent('[var=a]')")); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void TestIsLinearlyIndependentWithWrongInputONECharacter(){ | |||
getEvaluator().getBooleanResult("isLinearlyIndependent(a)"); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void testIsLinearlyIndependentWithEmptyStringArgument() { | |||
getEvaluator().getBooleanResult("isLinearlyIndependent('')"); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void testIsLinearlyIndependentWithEmptyArgument() { | |||
getEvaluator().getBooleanResult("isLinearlyIndependent()"); | |||
} | |||
@Test(expected=UndefinedExerciseVariableException.class) | |||
public void testIsLinearlyIndependentWithoutExerciseVariable() { | |||
getEvaluator().getBooleanResult("isLinearlyIndependent('[var=j]')"); | |||
} | |||
@Test(expected=UndefinedFillInVariableException.class) | |||
public void testIsLinearlyIndependentWithoutInput() { | |||
getEvaluator().getBooleanResult("isLinearlyIndependent('[pos=42]')"); | |||
} | |||
</syntaxhighlight> | |||
===Hinweise=== | ===Hinweise=== |
Version vom 21. Juni 2017, 10:06 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
@Before
public void beforeTest(){
placeFillInVariable(1,new OpenMathObject() {
//[vector(QQ,[1,2,3]),vector(QQ,[3,3,3])]
@Override
protected String getPartialXML() {
return "<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>";
}
});
placeFillInVariable(2, OMParser.parse("1"));
placeExerciseVariable("a", new OpenMathObject() {
//[vector(QQ,[1,2,3]),vector(QQ,[3,3,3])]
@Override
protected String getPartialXML() {
return "<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>";
}
});
placeExerciseVariable("b", OMParser.parse("1"));
}
@Test
public void testIsLinearlyIndependent(){
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,1), vector(1,2)))"));
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1)))"));
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,1,0), vector(1,1,1)))"));
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,0,0), vector(1,1,1), vector(1.5, 1.5, 1.8)))"));
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,2,3), vector(3,3,3)))"));
}
@Test
public void testIsLinearlyIndependentWithInput(){
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,[pos=2],0), vector(1,1,[pos=2])))"));
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent('[pos=1]')"));
}
@Test
public void testIsLinearlyIndependentWithVariables(){
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,[var=b],0), vector(1,1,[var=b])))"));
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent('[var=a]')"));
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void TestIsLinearlyIndependentWithWrongInputONECharacter(){
getEvaluator().getBooleanResult("isLinearlyIndependent(a)");
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testIsLinearlyIndependentWithEmptyStringArgument() {
getEvaluator().getBooleanResult("isLinearlyIndependent('')");
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testIsLinearlyIndependentWithEmptyArgument() {
getEvaluator().getBooleanResult("isLinearlyIndependent()");
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testIsLinearlyIndependentWithoutExerciseVariable() {
getEvaluator().getBooleanResult("isLinearlyIndependent('[var=j]')");
}
@Test(expected=UndefinedFillInVariableException.class)
public void testIsLinearlyIndependentWithoutInput() {
getEvaluator().getBooleanResult("isLinearlyIndependent('[pos=42]')");
}