~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to macros/elem/cosm.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function x=cosm(a)
 
2
//   cosm - computes the matrix cosine 
 
3
//%CALLING SEQUENCE
 
4
//   x=cosm(a)
 
5
//%PARAMETERS
 
6
//   a   : square hermitian or diagonalizable matrix
 
7
//   x   : square hermitian matrix
 
8
//!
 
9
// Copyright INRIA
 
10
if type(a)<>1 then error(53),end
 
11
if a==[] then x=[],return,end
 
12
 
 
13
if norm(imag(a),1)==0 then
 
14
  x=real(expm(%i*a))
 
15
else
 
16
  x=0.5*(expm(%i*a)+expm(-%i*a));
 
17
end