decomposition

Decompose integers larger than 100 digits [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-22 09:06:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . X and Y are integers larger than 100 digits. Find the integer P which is within the range [ X , Y [ and that guaranties the "best" prime decomposition (i.e. the decomposition with the most unique prime factors). What I've done is just check the primality and decompose each number in the range and find the number

Tuples and unpacking assignment support in C#?

隐身守侯 提交于 2019-12-22 02:06:34
问题 In Python I can write def myMethod(): #some work to find the row and col return (row, col) row, col = myMethod() mylist[row][col] # do work on this element But in C# I find myself writing out int[] MyMethod() { // some work to find row and col return new int[] { row, col } } int[] coords = MyMethod(); mylist[coords[0]][coords[1]] //do work on this element The Pythonic way is obivously much cleaner. Is there a way to do this in C#? 回答1: There's a set of Tuple classes in .NET: Tuple<int, int>

Time series and stl in R: Error only univariate series are allowed

懵懂的女人 提交于 2019-12-18 19:27:15
问题 I am doing analysis on hourly precipitation on a file that is disorganized. However, I managed to clean it up and store it in a dataframe (called CA1) which takes the form as followed: Station_ID Guage_Type Lat Long Date Time_Zone Time_Frame H0 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 H22 H23 1 4457700 HI 41.52 124.03 1948-07-01 8 LST 0 0 0 0 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0 0 0 0 0 0 0 0 0 0 2 4457700 HI 41.52 124.03 1948

Generating the partitions of a number

社会主义新天地 提交于 2019-12-17 02:44:26
问题 I needed an algorithm to generate all possible partitions of a positive number, and I came up with one (posted as an answer), but it's exponential time. The algorithm should return all the possible ways a number can be expressed as the sum of positive numbers less than or equal to itself. So for example for the number 5 , the result would be: 5 4+1 3+2 3+1+1 2+2+1 2+1+1+1 1+1+1+1+1 So my question is: is there a more efficient algorithm for this? EDIT: Question was titled "Sum decomposition of

QR decomposition and Choleski decomposition in R

左心房为你撑大大i 提交于 2019-12-14 04:19:17
问题 I recently read about how the R matrix of QR decomposition can be calculated using the Choleski decomposition. The relation is: R = Choleski-decomposition(A^TA) Example: > A=matrix(c(1,2,3,2,3,5,1,3,2), nrow=3) > A [,1] [,2] [,3] [1,] 1 2 1 [2,] 2 3 3 [3,] 3 5 2 > AtA = t(A)%*%A > AtA [,1] [,2] [,3] [1,] 14 23 13 [2,] 23 38 21 [3,] 13 21 14 Now calculating QR and Choleski decomposition: > chol(AtA) [,1] [,2] [,3] [1,] 3.741657 6.147009 3.4743961 [2,] 0.000000 0.462910 -0.7715167 [3,] 0.000000

What is the auto Bracketed List Syntax?

可紊 提交于 2019-12-13 12:14:49
问题 W.F. gave a now-deleted answer to my question here which used the line: auto [x, y] = div_t{ 1, 0 }; From the code in the answer it looks like that's like a tie for the div_t struct. I was hoping that someone could explain what was going on here. The complete function code was as follows: constexpr bool first_quot() { auto [x, y] = std::div_t{1, 0}; (void)y; return x; } 回答1: In the most most recent draft of the C++17 specification it's called "Decomposition declarations" and is defined in

“NA” results in Decomposition of Additive Time Series in R

爷,独闯天下 提交于 2019-12-12 04:42:43
问题 I'm trying to understand my "decomposition of additive time series" graph. Here's my code: dbs_discs <- ts(RC$Disconnects, frequency =12, start=c(2013,1)) discs_dbs <- decompose(dbs_discs) plot(discs_dbs) discs_dbs and my results: $trend Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2013 NA NA NA NA NA NA 301.8891 302.4746 302.6317 303.1842 304.2663 304.2212 2014 304.6779 306.3847 309.0182 310.5303 309.9420 309.1160 307.1276 304.2277 302.4454 301.2108 300.1494 299.7908 2015 299.5936 299

sklearn StandardScaler differece between “with_std=False or True” and “with_mean=False or True”

时光毁灭记忆、已成空白 提交于 2019-12-11 02:24:42
问题 I am trying to standardize some data to be able to apply PCA to it. I am using sklearn.preprocessing.StandardScaler. I am having trouble to understand the difference between using "True" or "False" in the parameters "with_mean" and "with_std". Here is the description of the command: https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html Can someone give a more extended explanation? Thank you very much! 回答1: I have provided more details in this post https:/

Database extraneous attributes and decomposition

℡╲_俬逩灬. 提交于 2019-12-11 02:18:15
问题 I am kind of confused on the notion of extraneous attributes and a proper decomposition into 3NF. For example, I have the following relation: r(A,B,C,D,E,F) F = FD's F = {A-> BCD, BC-> DE, B->D, D->A} I want to compute the canonical cover in order to decompose it into 3NF using an algorithm. So I have to remove extraneous attributes from the FD's. I computed A+. B+, C+, D+ (A+ = ABCDE, B+ = BD, C+ = C, D+ = AD) I started trying to find extraneous attributes. First I looked at attributes in β

Eigenvector (Spectral) Decomposition

此生再无相见时 提交于 2019-12-10 11:29:52
问题 I am trying to find a program in C code that will allow me to compute a eigenvalue (spectral) decomposition for a square matrix. I am specifically trying to find code where the highest eigenvalue (and therefore its associated eigenvalue) are located int the first column. The reason I need the output to be in this order is because I am trying to compute eigenvector centrality and therefore I only really need to calculate the eigenvector associated with the highest eigenvalue. Thanks in advance