Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function SolvePoly(ParamArray CoeffA() As Variant)
- Dim i As Long
- Dim PArray As Variant
- Dim Num_Coeff As Long
- Dim Degree As Long
- Dim Res As Variant
- Num_Coeff = UBound(CoeffA) + 1
- Degree = Num_Coeff - 1
- ReDim PArray(1 To Num_Coeff, 1 To 1)
- For i = 0 To Num_Coeff - 1
- If IsNumeric(CoeffA(i)) Then
- PArray(i + 1, 1) = CoeffA(i)
- Else
- PArray(i + 1, 1) = CoeffA(i).Value2
- End If
- Next i
- Select Case Num_Coeff
- Case Is < 3
- Res = "Num_Coeff must be >= 3"
- Case Is < 4
- Res = Quadratic(PArray)
- Case 4
- Res = CubicC(PArray)
- Case 5
- Res = Quartic(PArray)
- Case Else
- Res = RPolyJT(PArray)
- End Select
- If IsArray(Res) Then
- Res = SortRootResult(Res, Degree, 0.0000000001)
- SolvePoly = WorksheetFunction.Transpose(Res)
- Else
- SolvePoly = Res
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment