src/HOL/Predicate_Compile_Examples/Predicate_Compile_Quickcheck_Examples.thy
changeset 69597 ff784d5a5bfb
parent 68386 98cf1c823c48
equal deleted inserted replaced
69596:c8a2755bf220 69597:ff784d5a5bfb
   293 definition "scalar_product v w = (\<Sum> (x, y)\<leftarrow>zip v w. x * y)"
   293 definition "scalar_product v w = (\<Sum> (x, y)\<leftarrow>zip v w. x * y)"
   294 
   294 
   295 definition mv :: "('a :: semiring_0) list list \<Rightarrow> 'a list \<Rightarrow> 'a list"
   295 definition mv :: "('a :: semiring_0) list list \<Rightarrow> 'a list \<Rightarrow> 'a list"
   296   where [simp]: "mv M v = map (scalar_product v) M"
   296   where [simp]: "mv M v = map (scalar_product v) M"
   297 text \<open>
   297 text \<open>
   298   This defines the matrix vector multiplication. To work properly @{term
   298   This defines the matrix vector multiplication. To work properly \<^term>\<open>matrix M m n \<and> length v = n\<close> must hold.
   299 "matrix M m n \<and> length v = n"} must hold.
       
   300 \<close>
   299 \<close>
   301 
   300 
   302 subsection "Compressed matrix"
   301 subsection "Compressed matrix"
   303 
   302 
   304 definition "sparsify xs = [i \<leftarrow> zip [0..<length xs] xs. snd i \<noteq> 0]"
   303 definition "sparsify xs = [i \<leftarrow> zip [0..<length xs] xs. snd i \<noteq> 0]"