Numpy 的 negative(~)
方法將輸入數組中的每個值乘以 -1
。請注意,將返回一個新的 Numpy 數組。
參數
1. a
| array-like
第一個輸入數組。
2. out
| Numpy array
| optional
您可以將計算的平均值放入 out
指定的數組中,而不是創建新數組。
3. where
| boolean
的array
| optional
標記為 False 的值將被忽略,即它們的原始值將未被初始化。如果指定了 out 參數,行為會略有不同 - 原始值將保持不變。
返回值
如果 a
是標量,則返回標量,否則返回 Numpy 數組。
例子
基本用法
a = np.array([1,-2,3])
b = np.negative(a)
b
array([-1, 2, -3])
相關用法
- Python networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path用法及代碼示例
- Python networkx.classes.function.edge_subgraph用法及代碼示例
- Python networkx.algorithms.tree.mst.maximum_spanning_edges用法及代碼示例
- Python networkx.algorithms.bipartite.basic.color用法及代碼示例
- Python networkx.algorithms.bipartite.cluster.latapy_clustering用法及代碼示例
- Python networkx.readwrite.json_graph.adjacency_data用法及代碼示例
- Python networkx.algorithms.bipartite.edgelist.generate_edgelist用法及代碼示例
- Python next方法用法及代碼示例
- Python networkx.Graph.neighbors用法及代碼示例
- Python networkx.DiGraph.__contains__用法及代碼示例
- Python networkx.drawing.nx_pylab.draw_random用法及代碼示例
- Python networkx.convert_matrix.to_pandas_edgelist用法及代碼示例
- Python networkx.DiGraph.__init__用法及代碼示例
- Python networkx.algorithms.cycles.recursive_simple_cycles用法及代碼示例
- Python networkx.drawing.layout.random_layout用法及代碼示例
- Python networkx.algorithms.link_prediction.within_inter_cluster用法及代碼示例
- Python networkx.algorithms.non_randomness.non_randomness用法及代碼示例
- Python networkx.algorithms.traversal.depth_first_search.dfs_tree用法及代碼示例
- Python networkx.MultiGraph.clear用法及代碼示例
- Python networkx.algorithms.operators.product.cartesian_product用法及代碼示例
- Python networkx.algorithms.traversal.depth_first_search.dfs_labeled_edges用法及代碼示例
- Python networkx.DiGraph.number_of_edges用法及代碼示例
- Python networkx.algorithms.tree.operations.join用法及代碼示例
- Python networkx.generators.random_graphs.random_shell_graph用法及代碼示例
- Python networkx.classes.function.is_weighted用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | negative method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。