IsLinearlyIndependent

Aus JACK Wiki
Wechseln zu: Navigation, Suche

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

  • vektoren - List von Vektor, die auf lineare Unabhängigkeit geprüft werden sollen

Return Value

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();
}