IsLinearlyIndependent: Unterschied zwischen den Versionen

Aus JACK Wiki
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">
@Before
@BeforeClass
public void beforeTest(){
public static void beforeTest() {
  placeFillInVariable(1,new OpenMathObject() {
    //[vector(QQ,[1,2,3]),vector(QQ,[3,3,3])]
// set(vector(1,2,3),vector(3,3,3))
    @Override
isLinearlyIndependentFillInVariableMap.put(1, OMConverter.toObject(
    protected String getPartialXML() {
"<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>"));
      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>";
isLinearlyIndependentFillInVariableMap.put(2, OMConverter.toObject("<OMOBJ><OMI>1</OMI></OMOBJ>"));
    }
 
  });
// set(vector(1,2,3),vector(3,3,3))
  placeFillInVariable(2, OMParser.parse("1"));
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));
}


  placeExerciseVariable("a", new OpenMathObject() {
@Test
    //[vector(QQ,[1,2,3]),vector(QQ,[3,3,3])]
public void testIsLinearlyIndependentWithInput1() {
    @Override
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,[pos=2],0), vector(1,1,[pos=2])))",
    protected String getPartialXML() {
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
      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
@Test
public void testIsLinearlyIndependent(){
public void testIsLinearlyIndependentWithInput2() {
  assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,1), vector(1,2)))"));
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent('[pos=1]')",
  assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1)))"));
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
  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
@Test
public void testIsLinearlyIndependentWithInput(){
public void testIsLinearlyIndependentWithVariables1() {
  assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,[pos=2],0), vector(1,1,[pos=2])))"));
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent(set(vector(1,[var=b],0), vector(1,1,[var=b])))",
  assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent('[pos=1]')"));
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
}


@Test
@Test
public void testIsLinearlyIndependentWithVariables(){
public void testIsLinearlyIndependentWithVariables2() {
  assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent(set(vector(1,[var=b],0), vector(1,1,[var=b])))"));
assertTrue(Evaluator.getBooleanResult("isLinearlyIndependent('[var=a]')",
assertTrue(getEvaluator().getBooleanResult("isLinearlyIndependent('[var=a]')"));
isLinearlyIndependentExerciseVariableMap, isLinearlyIndependentFillInVariableMap));
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = ParserException.class)
public void TestIsLinearlyIndependentWithWrongInputONECharacter(){
public void TestIsLinearlyIndependentWithWrongInputONECharacter() {
  getEvaluator().getBooleanResult("isLinearlyIndependent(a)");
Evaluator.getBooleanResult("isLinearlyIndependent(ba)", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testIsLinearlyIndependentWithEmptyStringArgument() {
public void testIsLinearlyIndependentWithEmptyStringArgument() {
  getEvaluator().getBooleanResult("isLinearlyIndependent('')");
Evaluator.getBooleanResult("isLinearlyIndependent('')", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testIsLinearlyIndependentWithEmptyArgument() {
public void testIsLinearlyIndependentWithEmptyArgument() {
  getEvaluator().getBooleanResult("isLinearlyIndependent()");
Evaluator.getBooleanResult("isLinearlyIndependent()", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedExerciseVariableException.class)
@Test(expected = UndefinedExerciseVariableException.class)
public void testIsLinearlyIndependentWithoutExerciseVariable() {
public void testIsLinearlyIndependentWithoutExerciseVariable() {
  getEvaluator().getBooleanResult("isLinearlyIndependent('[var=j]')");
Evaluator.getBooleanResult("isLinearlyIndependent('[var=j]')", isLinearlyIndependentExerciseVariableMap,
isLinearlyIndependentFillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedFillInVariableException.class)
@Test(expected = UndefinedFillInVariableException.class)
public void testIsLinearlyIndependentWithoutInput() {
public void testIsLinearlyIndependentWithoutInput() {
  getEvaluator().getBooleanResult("isLinearlyIndependent('[pos=42]')");
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();
}

Hinweise

  • Die Funktionen Set und vector setzen die Vektoren in die richtige Schreibweise.