tensors.scm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #| -*-Scheme-*-
  2. Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
  3. 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  4. 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Massachusetts
  5. Institute of Technology
  6. This file is part of MIT/GNU Scheme.
  7. MIT/GNU Scheme is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11. MIT/GNU Scheme is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with MIT/GNU Scheme; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
  18. USA.
  19. |#
  20. ;;;; Testing a function for being a tensor field.
  21. ;;; To be a tensor field a function must be linear
  22. ;;; over the scalar function field in each of its
  23. ;;; arguments.
  24. ;;; Each argument of a tensor field must be either
  25. ;;; a one-form field or a vector field.
  26. ;;; The test is done with respect to some coordinate
  27. ;;; system. The types of the arguments are specified
  28. ;;; in a list.
  29. (define (tensor-test T types coordsys)
  30. (let ((args (map (literal-field coordsys) types))
  31. (f ((literal-field coordsys) 'scalar)))
  32. (map (lambda (i)
  33. (let ((thing
  34. ((literal-field coordsys) (ref types i))))
  35. ((- (apply T
  36. (list-with-substituted-coord
  37. args i
  38. (+ (* f (ref args i))
  39. thing)))
  40. (+ (* f (apply T args))
  41. (apply T
  42. (list-with-substituted-coord
  43. args i
  44. thing))))
  45. (typical-point coordsys))))
  46. (iota (length types)))))
  47. (define* ((literal-field coordsys) type)
  48. (case type
  49. ((scalar function)
  50. (literal-manifold-function
  51. (generate-uninterned-symbol 'g)
  52. coordsys))
  53. ((up vector)
  54. (literal-vector-field
  55. (generate-uninterned-symbol 'v)
  56. coordsys))
  57. ((down 1form one-form)
  58. (literal-1form-field
  59. (generate-uninterned-symbol 'omega)
  60. coordsys))
  61. (else
  62. (error "Bad type list" type)))) ; FBE: types -> type
  63. #|
  64. (tensor-test
  65. (Riemann (covariant-derivative (literal-Cartan 'G R3-rect)))
  66. '(1form vector vector vector)
  67. R3-rect)
  68. #|
  69. (0 0 0 0)
  70. |#
  71. (define* ((F nabla) omega u v)
  72. (omega ((nabla u) v)))
  73. (tensor-test
  74. (F (covariant-derivative (literal-Cartan 'G R3-rect)))
  75. '(1form vector vector)
  76. R3-rect)
  77. #|
  78. (0 0 <Mess>)
  79. |#
  80. (define* ((G nabla) omega u v)
  81. (omega ((torsion-vector nabla) u v)))
  82. (tensor-test
  83. (G (covariant-derivative (literal-Cartan 'G R3-rect)))
  84. '(1form vector vector)
  85. R3-rect)
  86. #|
  87. (0 0 0)
  88. |#
  89. |#