コード例 #1
0
 public void ScalarMultiplyAndDivide()
 {
   FloatVector a = new FloatVector(new float[4]{0,1,2,3});
   FloatVector c = new FloatVector(a);
   FloatVector d = new FloatVector(a);
   float scal = -4;
     
   c.Multiply(scal);
   d.Divide(scal);
     
   Assert.AreEqual(c[0],a[0]*scal);
   Assert.AreEqual(c[1],a[1]*scal);
   Assert.AreEqual(c[2],a[2]*scal);
   Assert.AreEqual(c[3],a[3]*scal);  
   
   Assert.AreEqual(d[0],a[0]/scal);
   Assert.AreEqual(d[1],a[1]/scal);
   Assert.AreEqual(d[2],a[2]/scal);
   Assert.AreEqual(d[3],a[3]/scal);
   
   c = a*scal;
   
   Assert.AreEqual(c[0],a[0]*scal);
   Assert.AreEqual(c[1],a[1]*scal);
   Assert.AreEqual(c[2],a[2]*scal);
   Assert.AreEqual(c[3],a[3]*scal);  
   
   c = scal*a;
   
   Assert.AreEqual(c[0],a[0]*scal);
   Assert.AreEqual(c[1],a[1]*scal);
   Assert.AreEqual(c[2],a[2]*scal);
   Assert.AreEqual(c[3],a[3]*scal);
 }