Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
6ea753ed
Commit
6ea753ed
authored
Jun 14, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accelerated function LARGE (get only no empty values)
parent
9ed6855e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
98 deletions
+95
-98
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+34
-31
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+61
-67
No files found.
cell/model/FormulaObjects/parserFormula.js
View file @
6ea753ed
...
...
@@ -715,27 +715,23 @@ cArea.prototype.foreach = function ( action ) {
r
.
_foreach2
(
action
);
}
};
cArea
.
prototype
.
_parseCellValue
=
function
(
cell
)
{
var
result
,
cellType
,
cellValue
;
if
(
cell
)
{
cellType
=
cell
.
getType
();
cellValue
=
cell
.
getValueWithoutFormat
();
if
(
cellType
===
CellValueType
.
Number
)
{
result
=
cell
.
isEmptyTextString
()
?
new
cEmpty
()
:
new
cNumber
(
cellValue
);
}
else
if
(
cellType
===
CellValueType
.
Bool
)
{
result
=
new
cBool
(
cellValue
);
}
else
if
(
cellType
===
CellValueType
.
Error
)
{
result
=
new
cError
(
cellValue
);
}
else
if
(
cellType
===
CellValueType
.
String
)
{
result
=
new
cString
(
cellValue
);
}
else
{
result
=
cell
.
isEmptyTextString
()
?
checkTypeCell
(
""
+
cellValue
)
:
new
cNumber
(
cellValue
);
}
}
else
{
result
=
new
cEmpty
();
}
return
result
;
};
cArea
.
prototype
.
_parseCellValue
=
function
(
cell
)
{
var
result
=
null
,
cellType
,
cellValue
;
if
(
cell
)
{
cellType
=
cell
.
getType
();
cellValue
=
cell
.
getValueWithoutFormat
();
if
(
cellType
===
CellValueType
.
Number
)
{
result
=
cell
.
isEmptyTextString
()
?
new
cEmpty
()
:
new
cNumber
(
cellValue
);
}
else
if
(
cellType
===
CellValueType
.
Bool
)
{
result
=
new
cBool
(
cellValue
);
}
else
if
(
cellType
===
CellValueType
.
Error
)
{
result
=
new
cError
(
cellValue
);
}
else
if
(
cellType
===
CellValueType
.
String
)
{
result
=
new
cString
(
cellValue
);
}
}
return
result
||
new
cEmpty
();
};
cArea
.
prototype
.
foreach2
=
function
(
action
)
{
var
t
=
this
,
r
=
this
.
getRange
();
if
(
r
)
{
...
...
@@ -744,16 +740,23 @@ cArea.prototype.foreach2 = function ( action ) {
}
);
}
};
cArea
.
prototype
.
getMatrix
=
function
()
{
var
t
=
this
,
arr
=
[],
r
=
this
.
getRange
();
r
.
_foreach2
(
function
(
cell
,
i
,
j
,
r1
,
c1
)
{
if
(
!
arr
[
i
-
r1
])
{
arr
[
i
-
r1
]
=
[];
}
arr
[
i
-
r1
][
j
-
c1
]
=
t
.
_parseCellValue
(
cell
);
}
);
return
arr
;
};
cArea
.
prototype
.
getMatrix
=
function
()
{
var
t
=
this
,
arr
=
[],
r
=
this
.
getRange
();
r
.
_foreach2
(
function
(
cell
,
i
,
j
,
r1
,
c1
)
{
if
(
!
arr
[
i
-
r1
])
{
arr
[
i
-
r1
]
=
[];
}
arr
[
i
-
r1
][
j
-
c1
]
=
t
.
_parseCellValue
(
cell
);
});
return
arr
;
};
cArea
.
prototype
.
getValuesNoEmpty
=
function
()
{
var
t
=
this
,
arr
=
[],
r
=
this
.
getRange
();
r
.
_foreachNoEmpty
(
function
(
cell
)
{
arr
.
push
(
t
.
_parseCellValue
(
cell
));
});
return
[
arr
];
};
cArea
.
prototype
.
getRefMatrix
=
function
()
{
var
t
=
this
,
arr
=
[],
r
=
this
.
getRange
();
r
.
_foreach2
(
function
(
cell
,
i
,
j
,
r1
,
c1
)
{
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
6ea753ed
...
...
@@ -2407,86 +2407,80 @@ cKURT.prototype.getInfo = function () {
};
};
function
cLARGE
()
{
// cBaseFunction.call( this, "LARGE" );
// this.setArgumentsMin( 2 );
// this.setArgumentsMax( 2 );
// this.setFormat( this.formatType.noneFormat );
this
.
name
=
"
LARGE
"
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
argumentsMin
=
2
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
2
;
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
};
this
.
numFormat
=
this
.
formatType
.
noneFormat
;
}
cLARGE
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cLARGE
.
prototype
.
Calculate
=
function
(
arg
)
{
function
cLARGE
()
{
this
.
name
=
"
LARGE
"
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
argumentsMin
=
2
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
2
;
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
};
this
.
numFormat
=
this
.
formatType
.
noneFormat
;
}
function
frequency
(
A
,
k
)
{
cLARGE
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cLARGE
.
prototype
.
_getValue
=
function
(
arg0
,
arg1
)
{
if
(
cElementType
.
error
===
arg1
.
type
)
{
return
arg1
;
}
var
tA
=
[];
arg1
=
arg1
.
getValue
();
if
(
arg1
<=
0
)
{
return
new
cError
(
cErrorType
.
not_available
);
}
for
(
var
i
=
0
;
i
<
A
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
A
[
i
].
length
;
j
++
)
{
if
(
A
[
i
][
j
]
instanceof
cError
)
{
return
A
[
i
][
j
];
}
else
if
(
A
[
i
][
j
]
instanceof
cNumber
)
{
tA
.
push
(
A
[
i
][
j
].
getValue
()
);
}
else
if
(
A
[
i
][
j
]
instanceof
cBool
)
{
tA
.
push
(
A
[
i
][
j
].
tocNumber
().
getValue
()
);
var
v
,
tA
=
[];
for
(
var
i
=
0
;
i
<
arg0
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
arg0
[
i
].
length
;
j
++
)
{
v
=
arg0
[
i
][
j
];
if
(
cElementType
.
error
===
v
.
type
)
{
return
v
;
}
else
if
(
cElementType
.
number
===
v
.
type
)
{
tA
.
push
(
v
.
getValue
());
}
else
if
(
cElementType
.
bool
===
v
.
type
)
{
tA
.
push
(
v
.
tocNumber
().
getValue
()
);
}
}
}
tA
.
sort
(
AscCommon
.
fSortDescending
);
if
(
k
.
getValue
()
>
tA
.
length
||
k
.
getValue
()
<=
0
)
return
new
cError
(
cErrorType
.
not_available
);
else
return
new
cNumber
(
tA
[
k
.
getValue
()
-
1
]
);
}
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
];
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArray
)
{
arg0
=
arg0
.
getMatrix
();
}
else
if
(
arg0
instanceof
cArea3D
)
{
arg0
=
arg0
.
getMatrix
()[
0
];
}
else
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
].
first
);
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
=
arg1
.
getElement
(
0
);
}
arg1
=
arg1
.
tocNumber
();
if
(
arg1
>
tA
.
length
)
{
return
new
cError
(
cErrorType
.
not_available
);
}
else
{
return
new
cNumber
(
tA
[
arg1
-
1
]);
}
};
cLARGE
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
];
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
arg0
=
arg0
.
getValuesNoEmpty
();
}
else
if
(
cElementType
.
array
===
arg0
.
type
)
{
arg0
=
arg0
.
getMatrix
();
}
else
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg0
=
arg0
.
getMatrix
()[
0
];
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
if
(
arg1
instanceof
cError
)
return
this
.
value
=
arg1
;
return
this
.
value
=
frequency
(
arg0
,
arg1
);
if
(
cElementType
.
cellsRange
===
arg1
.
type
||
cElementType
.
cellsRange3D
===
arg1
.
type
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
].
first
);
}
else
if
(
cElementType
.
array
===
arg1
.
type
)
{
arg1
=
arg1
.
getElement
(
0
);
}
};
cLARGE
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( array , k )
"
arg1
=
arg1
.
tocNumber
();
return
this
.
value
=
this
.
_getValue
(
arg0
,
arg1
);
};
cLARGE
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( array , k )
"
};
};
};
function
cLINEST
()
{
cBaseFunction
.
call
(
this
,
"
LINEST
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment