 |
|
| 이전 주제 보기 :: 다음 주제 보기 |
| 글쓴이 |
메시지 |
이승중
가입: 2010년 6월 22일 올린 글: 561
|
올려짐: 2011년11월21일 10:52 주제: 실습 9 테스트 |
|
|
(* 1. Test Case *)
let a = Integer.make "5"
let b = Integer.make "6"
let _ = Integer.print (Integer.add a b)
let _ = print_newline()
let _ = Integer.print (Integer.mul a b)
let _ = print_newline()
(* 2. Test Case *)
let c = IntVector3.make [3;4;5]
let d = IntVector3.make [5;6;7]
let _ = IntVector3.print (IntVector3.add c d)
let _ = print_newline()
let _ = IntVector3.print (IntVector3.mul c 3)
let _ = print_newline()
let _ = print_int (IntVector3.dot c d)
(* 3. Test case $*)
module FV3 = Vector3 (FloatingPoint)
let c = FV3.make [3.0;4.22;5.23]
let d = FV3.make [5.1;6.2;7.3]
let _ = FV3.print (FV3.add c d)
let _ = print_newline()
let _ = FV3.print (FV3.mul c 3.7)
let _ = print_newline()
let _ = FloatingPoint.print (FV3.dot c d)
(* 4. Test case *)
module Trait: TRAIT = struct let dim = 5 end
module FV5 = VectorN (FloatingPoint) (Trait)
let c = FV5.make [3.0;4.22;5.23;3.4;2.3]
let d = FV5.make [5.1;6.2;7.3;2.3;3.2]
let _ = FV5.print (FV5.add c d)
let _ = print_newline()
let _ = FV5.print (FV5.mul c 3.7)
let _ = print_newline()
let _ = FloatingPoint.print (FV5.dot c d)
이승중 가 2011년12월2일 17:38에 수정함, 총 1 번 수정됨 |
|
| 위로 |
|
 |
kernys
가입: 2011년 10월 26일 올린 글: 10
|
올려짐: 2011년11월21일 10:58 주제: 심플한 테스트 케이스 (....) |
|
|
module FloatVector3 = Vector3(FloatingPoint) ;;
(Integer.print Integer.zero);; (* 0 *)
(FloatingPoint.print FloatingPoint.zero);; (* 0. *)
(Integer.print (Integer.add (Integer.mul (Integer.make "3") (Integer.make "7")) (Integer.make "2")));; (* 23 *)
(FloatingPoint.print (FloatingPoint.add (FloatingPoint.mul (FloatingPoint.make "3.0") (FloatingPoint.make "7.0")) (FloatingPoint.make "2")));; (* 23. *)
let a = (FloatVector3.make (List.map (FloatingPoint.make) ["1.37"; "2.90"; "3.22";])) in
let b = (FloatVector3.make (List.map (FloatingPoint.make) ["1.37"; "2.90"; "3.22";])) in
(FloatVector3.print (FloatVector3.add a b));; (* (2.74, 5.8, 6.44) *)
let a = (FloatVector3.make (List.map (FloatingPoint.make) ["1.37"; "2.90"; "3.22";])) in
let b = (FloatingPoint.make "7.0") in
(FloatVector3.print (FloatVector3.mul a b));; (* (9.59, 20.3, 22.54) *)
let a = (FloatVector3.make (List.map (FloatingPoint.make) ["1.37";])) in
(FloatVector3.print a);; (* InvalidInput *)
module FloatVector5 = VectorN (FloatingPoint) (struct let dim = 5 end)
let strList = ["1.37"; "2.90"; "3.22"; "33.22"; "33.33"];;
let numList = (List.map (FloatingPoint.make) strList);;
let a = (FloatVector5.make numList) in
(FloatVector5.print a);; (* (1.37, 2.9, 3.22, 33.22, 33.33) *) |
|
| 위로 |
|
 |
김인섭
가입: 2011년 9월 27일 올린 글: 12
|
올려짐: 2011년11월21일 11:03 주제: 수정한 버전입니다. |
|
|
(* 1. Test Case *)
let a = Integer.make "5"
let b = Integer.make "6"
let _ = Integer.print (Integer.add a b)
let _ = print_newline()
let _ = Integer.print (Integer.mul a b)
let _ = print_newline()
(* 2. Test Case *)
let c = IntVector3.make [3;4;5]
let d = IntVector3.make [5;6;7]
let _ = IntVector3.print (IntVector3.add c d)
let _ = print_newline()
let _ = IntVector3.print (IntVector3.mul c 3)
let _ = print_newline()
let _ = print_int (IntVector3.dot c d)
let _ = print_newline()
(* 3. Test case $*)
module FV3 = Vector3 (FloatingPoint)
let c = FV3.make (List.map (FloatingPoint.make) ["3.0";"4.22";"5.23"])
let d = FV3.make (List.map (FloatingPoint.make) ["5.1";"6.2";"7.3"])
let _ = FV3.print (FV3.add c d)
let _ = print_newline()
let _ = FV3.print (FV3.mul c (FloatingPoint.make "3.7"))
let _ = print_newline()
let _ = FloatingPoint.print (FV3.dot c d)
let _ = print_newline()
(* 4. Test case *)
module Trait: TRAIT = struct let dim = 5 end
module FV5 = VectorN (FloatingPoint) (Trait)
let c = FV5.make (List.map (FloatingPoint.make) ["3.0";"4.22";"5.23";"3.4";"2.3"] )
let d = FV5.make (List.map (FloatingPoint.make) ["5.1";"6.2";"7.3";"2.3";"3.2"] )
let _ = FV5.print (FV5.add c d)
let _ = print_newline()
let _ = FV5.print (FV5.mul c (FloatingPoint.make "3.7"))
let _ = print_newline()
let _ = FloatingPoint.print (FV5.dot c d)
let _ = print_newline() |
|
| 위로 |
|
 |
kernys
가입: 2011년 10월 26일 올린 글: 10
|
올려짐: 2011년11월21일 11:05 주제: Test Case 결과 포함. |
|
|
(* 1. Test Case *)
let a = Integer.make "5"
let b = Integer.make "6"
let _ = Integer.print (Integer.add a b) (* 11 *)
let _ = print_newline()
let _ = Integer.print (Integer.mul a b) (* 30 *)
let _ = print_newline()
(* 2. Test Case *)
let c = IntVector3.make [3;4;5]
let d = IntVector3.make [5;6;7]
let _ = IntVector3.print (IntVector3.add c d) (* (8, 10, 12) *)
let _ = print_newline()
let _ = IntVector3.print (IntVector3.mul c 3) (* (9, 12, 15) *)
let _ = print_newline()
let _ = print_int (IntVector3.dot c d) (* 74 *)
(* 3. Test case $*)
module FV3 = Vector3 (FloatingPoint)
let c = FV3.make (List.map (FloatingPoint.make) ["3.0";"4.22";"5.23"])
let d = FV3.make (List.map (FloatingPoint.make) ["5.1";"6.2";"7.3"])
let _ = FV3.print (FV3.add c d) (* (8.1, 10.42, 12.53) *)
let _ = print_newline()
let _ = FV3.print (FV3.mul c (FloatingPoint.make "3.7")) (* (11.1, 15.614, 19.351) *)
let _ = print_newline()
let _ = FloatingPoint.print (FV3.dot c d) (* 79.643 *)
(* 4. Test case *)
module Trait: TRAIT = struct let dim = 5 end
module FV5 = VectorN (FloatingPoint) (Trait)
let c = FV5.make (List.map (FloatingPoint.make) ["3.0";"4.22";"5.23";"3.4";"2.3"])
let d = FV5.make (List.map (FloatingPoint.make) ["5.1";"6.2";"7.3";"2.3";"3.2"])
let _ = FV5.print (FV5.add c d) (* (8.1, 10.42, 12.53, 5.7, 5.5) *)
let _ = print_newline()
let _ = FV5.print (FV5.mul c (FloatingPoint.make "3.7")) (* (11.1, 15.614, 19.351, 12.58, 8.51) *)
let _ = print_newline()
let _ = FloatingPoint.print (FV5.dot c d) (* 94.823 *) |
|
| 위로 |
|
 |
|
|
새로운 주제를 올릴 수 없습니다 답글을 올릴 수 없습니다 주제를 수정할 수 없습니다 올린 글을 삭제할 수 없습니다 투표를 할 수 없습니다
|
Powered by phpBB 2.0.21-7 (Debian) © 2001, 2005 phpBB Group Translated by kss & drssay
|