Home > Net >  An example of c # calculation duplication for help like sea quantity data
An example of c # calculation duplication for help like sea quantity data

Time:11-10

Good the great god ~

I have an example of calculating the duplication:

Outer loop has 1000, data of List , concrete is 1,2,4,7,13 inside such Numbers, length of uncertain
Circulate in 300000, the data for List , there is 1,2,3,7,29 such Numbers, length is 6

Yourself with the following algorithm, c # for each combination of calculate can repeat degree,

List ListA=new List (a);
ListA=XXX;//here to listA initialization 1000 digital string

List ListListB=new List (a);
ListListB=XXX;//here to listA initialization 300000 digital string

{foreach (var itemA in listA)
The foreach (var itemB listListB) in {
Int CFD=getcfd (itemA, itemB)
}
}

Add a method
Int getcfd (list Lista, list By) {
Int CFD=0;
The foreach (var itemINT lista) in {
If (by the contains (itemINT) cfd++;
}
The return of CFD;
}

The above calculation, the whole process is too time consuming,
I checked the Internet, according to the two layers of loop optimized code, there is no obvious change, then the getcfd method instead of the dictionary can either containsKey slightly better,

Behold a great god, and can cut down the calculation time,
Algorithm structure, for example, can reduce the time complexity,
Is the use of multithreading, for example, caching, reduce calculation times,

CodePudding user response:

Cosine similarity?

CodePudding user response:

Don't know you specific scenarios, cosine ignore the distance is only
See your original algorithm, seems to want to calculate proportion

Personally, I think you can take the maximum and minimum out, no intersection directly through

Or first than cosine characteristics, cosine approximation in than European feature

CodePudding user response:

refer to the second floor wanghui0380 response:
don't know you specific scenarios, cosine ignore the distance is only
See your original algorithm, seems to want to calculate proportion

Personally, I think you can take the maximum and minimum out, no intersection directly through

Or first than cosine characteristics, cosine approximation in than European feature


Indeed just calculating the repetition of two lists,
Specific scenarios, is int CFD=getcfd (itemA, itemB) after calculation, print the list of CFD range condition, only the judge me removed,

The above code, can optimize I can use either containsKey, heard that the time complexity is O (1),

CodePudding user response:

I actually didn't understand the topic,

List ListA=new List (a);
ListA=XXX;//here listA initialization 1000 digital string

List ListListB=new List (a);
ListListB=XXX;//here listA initialization 300000 digital string

Then the title List Where, again, and I don't know the List< above; List Put the string or List

CodePudding user response:

Where there is a repeat?

CodePudding user response:

With Parallel loop should be able to improve a little speed: Parallel. For/ForEach
If the List related to insert delete modify load-balanced across

CodePudding user response:

refer to 6th floor destruction illusion response:
with Parallel loop should be able to improve a little speed: Parallel. For/ForEach
If List involving inserted delete changes with load-balanced across

Now try the Parallel, the issue of nuclear ran full, feel or slow, from structure to tune,
Load-balanced across, I check today,
Thank you ~

CodePudding user response:

reference 7 floor of transit with the wind response:
Quote: refer to the sixth floor destruction illusion response:
with Parallel loop should be able to improve a little speed: Parallel. For/ForEach
If List involving inserted delete changes with load-balanced across

Now try the Parallel, the issue of nuclear ran full, feel or slow, from structure to tune,
Load-balanced across, I check today,
Thank you ~

Another method called bitmap method, because this collection are int, you can try to directly use an array subscript comparison

CodePudding user response:

The data into a temporary table, then use the SQL found out, how about the

CodePudding user response:

  •  Tags:  
  • C#
  • Related