게시판 인덱스

 
 FAQFAQ   검색검색   멤버리스트멤버리스트   사용자 그룹사용자 그룹   사용자 등록하기사용자 등록하기 
 개인 정보개인 정보   비공개 메시지를 확인하려면 로그인하십시오비공개 메시지를 확인하려면 로그인하십시오   로그인로그인 

실습 9 테스트

 
이 게시판은 잠겼으므로 글을 올리거나, 답변을 하거나 수정을 할 수 없습니다   이 주제는 잠겼으므로 답변을 하거나 수정을 할 수 없습니다     게시판 인덱스 -> 4190.210 Principles of Programming (Fall 2011)
이전 주제 보기 :: 다음 주제 보기  
글쓴이 메시지
이승중



가입: 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 *)
위로
사용자 정보 보기 비밀 메시지 보내기
이전 글 표시:   
이 게시판은 잠겼으므로 글을 올리거나, 답변을 하거나 수정을 할 수 없습니다   이 주제는 잠겼으므로 답변을 하거나 수정을 할 수 없습니다     게시판 인덱스 -> 4190.210 Principles of Programming (Fall 2011) 시간대: GMT + 9 시간(한국)
페이지 11

 
건너뛰기:  
새로운 주제를 올릴 수 없습니다
답글을 올릴 수 없습니다
주제를 수정할 수 없습니다
올린 글을 삭제할 수 없습니다
투표를 할 수 없습니다


Powered by phpBB 2.0.21-7 (Debian) © 2001, 2005 phpBB Group
Translated by kss & drssay