Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/ein/mkoperators.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/ein/mkoperators.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3188, Tue Mar 31 21:10:27 2015 UTC revision 3189, Thu Apr 2 18:49:21 2015 UTC
# Line 370  Line 370 
370    
371      (******************** Norm  ********************************)      (******************** Norm  ********************************)
372    
373            (*n.t.s tensor norms/normalize use high-il ops
374            *we can norm any size and use einapp
375            * normalize only implemented for vectors and use mid il-op
376            *)
377      (*get norm, but without the sqrt      (*get norm, but without the sqrt
378      * implemented as a summation over a modulate      * implemented as a summation over a modulate
379      *)      *)
# Line 400  Line 404 
404          in e          in e
405          end          end
406    
407         fun normalizeTT [] =E.EIN{params = [E.TEN(1,[])],index = [],body =  E.Tensor(0, [])}
408            | normalizeTT alpha =let
409            val expindex= specialize(alpha,0)
410            (*shift indices in the inner product*)
411            val expindexDot= specialize(alpha,length(alpha))
412            val sx= sumIds(length(alpha),length(alpha),alpha)
413            val f=E.Tensor(0, expindex)
414            val g=E.Tensor(1, expindexDot)
415            val e=
416                E.EIN{
417                params = [E.TEN(0,alpha) ,E.TEN(0,alpha)],
418                index = alpha,
419                body = E.Prod[f,E.Div(E.Const 1,E.Sqrt(E.Sum(sx, E.Prod[g,g])))]
420                }
421            in e
422            end
423    
424      fun normalizeFF(dim,[]) =E.EIN{params = [E.FLD(dim)],index = [],body =  E.Field(0, [])}      fun normalizeFF(dim,[]) =E.EIN{params = [E.FLD(dim)],index = [],body =  E.Field(0, [])}
425        | normalizeFF(dim,alpha) =let        | normalizeFF(dim,alpha) =let
426          val expindex= specialize(alpha,0)          val expindex= specialize(alpha,0)
# Line 458  Line 479 
479          E.Prod[E.Tensor(0, [E.C 0,E.C 1]),E.Tensor(0, [E.C 1,E.C 0])])          E.Prod[E.Tensor(0, [E.C 0,E.C 1]),E.Tensor(0, [E.C 1,E.C 0])])
480      }      }
481    
482        val detT3  = let
483            val a=E.Tensor(0, [E.C 0,E.C 0])
484            val b=E.Tensor(0, [E.C 0,E.C 1])
485            val c=E.Tensor(0, [E.C 0,E.C 2])
486            val d=E.Tensor(0, [E.C 1,E.C 0])
487            val e=E.Tensor(0, [E.C 1,E.C 1])
488            val f=E.Tensor(0, [E.C 1,E.C 2])
489            val g=E.Tensor(0, [E.C 2,E.C 0])
490            val h=E.Tensor(0, [E.C 2,E.C 1])
491            val i=E.Tensor(0, [E.C 2,E.C 2])
492            in E.EIN{
493                params = [E.TEN(0,[3,3])],
494                index= [],
495                body=E.Sub(
496                    E.Add[E.Prod[a,e,i],E.Prod[b,f,g],E.Prod[c,d,h]],
497                    E.Add[E.Prod[c,e,g], E.Prod[b,d,i],E.Prod[a,f,h]])
498                }
499            end
500    
501      val detF2  =E.EIN{      val detF2  =E.EIN{
502          params = [E.FLD 2], index= [],          params = [E.FLD 2], index= [],
503          body= E.Sub(E.Prod[E.Field(0, [E.C 0,E.C 0]),E.Field(0, [E.C 1,E.C 1])],          body= E.Sub(E.Prod[E.Field(0, [E.C 0,E.C 0]),E.Field(0, [E.C 1,E.C 1])],

Legend:
Removed from v.3188  
changed lines
  Added in v.3189

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0