-
Notifications
You must be signed in to change notification settings - Fork 4
/
dataArray.m
52 lines (40 loc) · 2.69 KB
/
dataArray.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(* ::Package:: *)
(************************************************************************)
(* This file was generated automatically by the Mathematica front end. *)
(* It contains Initialization cells from a Notebook file, which *)
(* typically will have the same name as this file except ending in *)
(* ".nb" instead of ".m". *)
(* *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs. Doing so is equivalent *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end. *)
(* *)
(* DO NOT EDIT THIS FILE. This entire file is regenerated *)
(* automatically each time the parent Notebook file is saved in the *)
(* Mathematica front end. Any changes you make to this file will be *)
(* overwritten. *)
(************************************************************************)
(* ::Input::Initialization:: *)
Echo["Loaded dataArray.m"];
(* ::Input::Initialization:: *)
ClearAll[CdataArray];
CdataArray::usage="CdataArray[payoffMatrix,xlist,printflag] creates the dataArray. It works either using the \"Speed\" model or the \"Memory\" model. It uses ineqmembers and Cinequalities internally and for the memory model it erases ineqmembers after use.";
CdataArray[payoffMatrix_,xlist_,printflag_:False]:=Module[{dataarray,head},
dataarray=Cinequalities[payoffMatrix[[##]]&,ineqmembers];If[printflag,Print[1," ",{ByteCount@dataarray,MemoryInUse[],MaxMemoryUsed[]}]];
Switch[MSEresources,
"Memory",head=Uncompress;ClearAll[ineqmembers],
"Speed",head=Identity;
];
groupIDs=
Developer`ToPackedArray[
Flatten[MapIndexed[Table[#2,{#1}]&,Length[head@#]&/@dataarray],1]
];
If[printflag,Print[2," ",{ByteCount@groupIDs,MemoryInUse[],MaxMemoryUsed[]}]];
dataarray=(head/@dataarray);If[printflag,Print[3," ",{ByteCount@dataarray,MemoryInUse[],MaxMemoryUsed[]}]];
dataarray=Flatten@dataarray;If[printflag,Print[4," ",{ByteCount@dataarray,MemoryInUse[],MaxMemoryUsed[]}]];
dataarray=Flatten@Normal@CoefficientArrays[#,xlist]&/@dataarray;If[printflag,Print[5," ",{ByteCount@dataarray,MemoryInUse[],MaxMemoryUsed[]}]];
Scan[If[Length[dataarray[[#]]]==1,dataarray[[#]]=PadRight[dataarray[[#]],Length[xlist]+1,0]]&,Range@Length@dataarray];If[printflag,Print[6," ",{ByteCount@dataarray,MemoryInUse[],MaxMemoryUsed[]}]];
dataArray=Developer`ToPackedArray[dataarray,Real]
];
Information[CdataArray,LongForm->False]