(* 13_06 *)

(* Require XMLgen_MC.nb ver >=0.04 *)
SetDirectory[NotebookDirectory[]];
<<XMLgenMC.mx;
TTS[mt_]:=ToString[TeXForm[StandardForm[mt]]];
TOT[mt_]:=ToString[OneLineTeXForm[mt]];
TOTT[mt_]:=ToString[OneLineTeXForm[Transpose[mt]]];
TOC[mt_,c_]:=TOTT[{Transpose[mt][[c]]}];
TTD[r_]:=StringReplace[TT[r],"\\frac"->"\\dfrac"];
Rnz[m_]:=(RandomInteger[m]+1)*(2*RandomInteger[1]-1); (* \\pm 1,\pm2,...,\pm(m+1) *)
Rpos[m_]:=RandomInteger[m]+1; (* 1,2,...,m+1 *)
Rbtw[m_]:=RandomInteger[2m]-m;
TTC[A_,n_]:=TOTT[{(Transpose[A])[[n]]}];
Col[A_,n_]:=Transpose[{A[[Range[Length[A]],n]]}];
ColCat[CL_]:=Join@@@(Transpose@CL);
RowCat[CL_]:=Join@@(CL);
PtString[M_]:=StringReplace[ToString[M],{"{"->"(","}"->")"}];
ai2tex[s_]:=StringReplace[TOT[s],Table["\\text{a"<>TOT[i]<>"}"->"{\\mathbf a}_"<>TOT[i],{i,1,5}]];
TpStr[L_]:="\\("<>TOT[L[[1]]]<>"\\times"<>TOT[L[[2]]]<>"\\)";
TpTpse[L_]:=If[L=={},{},{L[[2]],L[[1]]}];
PType[A_,B_]:=If[A=={}||B=={},Return[{}],
If[A[[2]]===B[[1]],Return[{A[[1]],B[[2]]}],Return[{}]]];
PTypeL[L_]:=Module[{ct,len,tmp},len=Length[L];
Which[len==0,Return[{}],len==1,Return[L[[1]]],
len==2,Return[PType[L[[1]],L[[2]]]],
True,tmp=L[[1]];For[ct=2,ct≤len,ct++,tmp=PType[tmp,L[[ct]]]];Return[tmp]]];
Title="1次変換を表す行列の定義";
SELNUM=4;
Single="true";
NUM=200;

PtString[{2,3}]

(* select pairs of matrices *)
We1={{1},{0}};We2={{0},{1}};
QtList={}; For[ct=1,ct≤300,ct++,
Cn=1;
MA=Table[Table[Rnz[3],2],2];
QtList=Append[QtList,{Cn,MA}]];
(* QtList=DeleteDuplicates[QtList]; *)
QtList=RandomSample[QtList,NUM];Length[QtList]

Clear[QtextF];QtextF[mm_]:=Module[{Cn,MA,p1,p2},
{Cn,MA}=QtList[[mm]];
p1=Transpose[Col[MA,1]][[1]];p2=Transpose[Col[MA,2]][[1]];
Return["平面の1次変換で\\((1,0)\\)を\\("<>PtString[p1]<>"\\)に"
<>"\\((0,1)\\)を\\("<>PtString[p2]<>"\\)に写す平面の1次変換表す行列を選べ."]];
QtextF[3]

For[ct=1,ct≤200,ct++,QtextF[ct]]

CListF[mm_]:=Module[{Cn,MA,ct,fs,ret={}},
{Cn,MA}=QtList[[mm]];fs="正解です.";
ret=Append[ret,{"\\("<>TOT[MA]<>"\\)",fs}];
Return[RandomSample[ret,Cn]]];

CListF[15]

ICListF[mm_]:=Module[{Cn,MA,MA1,ct,fs1,fs2,fs3,ret={}},
{Cn,MA}=QtList[[mm]];
fs1="点の座標は横に書きますが，1次変換を考えるときはベクトルとして扱うことに注意して下さい.";
fs2="平面の1次変換は定まりますが, 条件を満たしません.";
fs3="平面の1次変換を定めません.";
MA1=Transpose[MA];
ret=Append[ret,{"\\("<>TOT[MA1]<>"\\)",fs1}];
MA1=MA;MA1[[{1,2},1]]={1,0};
ret=Append[ret,{"\\("<>TOT[MA1]<>"\\)",fs2}];
MA1=MA;MA1[[{1,2},2]]={0,1};
ret=Append[ret,{"\\("<>TOT[MA1]<>"\\)",fs2}];
MA1=ColCat[{MA,IdentityMatrix[2]}];
ret=Append[ret,{"\\("<>TOT[MA1]<>"\\)",fs3}];
MA1=RowCat[{MA,IdentityMatrix[2]}];
ret=Append[ret,{"\\("<>TOT[MA1]<>"\\)",fs3}];
Return[RandomSample[ret,SELNUM-Cn]]];

MA={{a,b},{c,d}}

MA[[{1,2},1]]

ICListF[10]

For[ct=1,ct≤NUM,ct++,QtextF[ct];ICListF[ct]] (* Error check *)

GenerateMCxml[DFname[],"LA/13-06."<>Title<>"(MC1)",Title,NUM,Single,QtextF,CListF,ICListF]

ICListF[3]

Permutations[{1,2,3,4},{2}] /. Permutations[{1,2,3},{2}]Nothing

#->Nothing &/@ Permutations[{1,2,3},{2}]

MA={{3,5},{7,9}}

MA1=MA;MA1[[{1,2},1]]={{1},{0}};

MA1

RowCat[{IdentityMatrix[2],MA}]