Latest File Release

l4P5 (beta-003)2009-05-05 20:38
Loc (beta-005)2009-05-05 20:33
wrj4p5 (alpha-011)2009-05-05 20:41

最近の更新

2012-01-01
2010-03-25
2009-12-26
2009-05-06
2009-04-12
2009-03-02
2008-12-20
2008-08-08

Wikiガイド

サイドバー

ClassVec - the model of Linear Algebra with the linear operations

test applet and code is here

  1. /*[class] Vec 5/20/2008 by Classiclll
  2. * the model of Linear Algebra with the linear operations.
  3. * The index of Vecrices is 0-based -- e.g.,
  4. * elem(0) : the left mostelement
  5. * elem(idx) : the (idx+1)th element.
  6. * can solve the polynomial equation, all the roots are complex with DKA method
  7. * v[0]*x^n + v[1]*x^(n-1) + .... + v[n-1]*x^1 = b
  8. * - you can use the convinient, Vec realRoots(Mat root)
  9. * to get unique real roots if exist.
  10. */
  11. [members]
  12. static final Vec NaN //constant Vec of one Double.NaN(not a number)
  13. [constructer]
  14. Vec() //construct empty
  15. Vec(int length) //construct zero vector sized by "length"
  16. Vec(Vec v) //construct same to v
  17. Vec(double[] d, int length) //construct having d
  18. Vec(Loc v) //construct 3D vector, (x,y,z)
  19. [methods]
  20. <group #1 - Vector Operation - generator>
  21. Vec copy() //return the copy of me.
  22. Vec add(Vec m) //return me[i] + m[i]
  23. Vec add(double d) //return me[i] + d (scalar)
  24. Vec sub(Vec m) //return me[i] - m[i]
  25. Vec sub(double d) //return me[i] - d (scalar)
  26. Vec mul(Vec v) //return me[i] * v[i]
  27. Vec mul(double d) //return me[i] * d (scalar)
  28. Vec div(Vec v) //return me[i] / v[i]
  29. Vec div(double d) //return me[i] / d (scalar)
  30. Vec setSubVec(Vec subVec, int row) //ret[row+i] <= subVec[i][j]
  31. Vec SubVec(int start, int end) //return me[sRow->eRow]
  32. Vec SubVec(int[] selected) //retturn {{.},..{me[selRow][selCol]},..{.}}
  33. Mat transpose() //return the transpose of me.
  34. Vec inverse() //"me" must be square, otherwize null returned
  35. Mat cross(Vec v) //return Mat it's trace has me[i]*v[i]
  36. <group #2 - Scalar - information>
  37. double dot(Vec v) //return sum of me[i] * m[i]
  38. int length() //return the number of elmements
  39. double elem(int idx) //return the specified element
  40. double norm() //return the infinit(=maximum) norm of me.
  41. double normL2() //return the L2 norm of me.
  42. double sqNormL2() //return the sqare of the L2 norm of me.
  43. double dist(Vec v) //return euclid distance (=L2) between v and me.
  44. double dist2(Vec v) //return square of distance between v and me.
  45. boolean equals(Object object) //return value equolity between me and object
  46. boolean hasNaN() //return has me some Double.NaN
  47. boolean hasInf() //return has me some Double.Infinity
  48. boolean isNaN() //return is me containing NaN or Infinity
  49. <group #3 - Utilities - generator>
  50. double[] toArray() //return 2d array of me
  51. Loc toLoc() //return Loc of me (length must be 3)
  52. double[] arrayRef() //retuen the reference to 2d array of "me"
  53. // * modification may cause some trouble.
  54. String toString() //get the string expression of me.
  55. <group #4 - High level operator>
  56. double polyValueAt(double x) //return me[0]*x^n + ... + me[n-1]*x
  57. Vec realRoots(Mat root)
  58. // Returns only unique real root with chopping the small imagenary of solve(b).
  59. Mat solve(double b)
  60. /* Returns the all roots of the following polynomial equation by the DKA Method.
  61. me[0]*x^n + ...+me[k]*x^(n-k)+... + me[n-1]*x - b = 0.
  62. solution matrix has
  63. solution.rowDim() always 2, (number of parts of the complex expression)
  64. solution.colDim() the number of solution pairs
  65. solution[0][k] the real part of (k+1)th solution
  66. solution[1][k] the imaginary part of (k+1)th solution */